User manual - アプリケーション移行ガイド(2014年10月10日)
17
2) サンプルを用いた改編例
マルチドロップ IrDA ファイル送受信サンプルを例として、FLINK IrDA への改編を説明します。
[リスト 2-1] マルチドロップ IrDA
#include <CU_MULTI.H>
ER Ret;
DAT_COM_STR ComParam;
CU_FILE_INFO_FORM FileInfo[4];
UH FileCnt;
UW ComStat, BiosStat;
B SendRecvMode; // MODE_RECV or MODE_SEND
UB GraphPos = 0;
cu_stopKeySet( CU_FNC_1 );
memset(&ComParam, 0, sizeof(DAT_COM_STR));
ComParam.speed = B_19200;
ComParam.length = CHAR_8;
ComParam.parity = PARI_NON;
ComParam.stop_bit = STOP_1;
if( cu_open( COM0, CU_CNCT_MULT, &ComParam ) != E_OK ){
cu_readErrStat( COM0, &ComStat, &BiosStat );
Ret = (ComStat & 0xFF);
cu_stopKeySet( CU_FNC_NON );
return( Ret );
}
cu_setDrive( CU_DRIVE_B );
memset(&FileInfo, 0, sizeof(CU_FILE_INFO_FORM) * 4);
if( SendRecvMode == MODE_RECV ){
memcpy( FileInfo[0].fileName, "XXXXXXX DAT", 11 );
memcpy( FileInfo[1].fileName, "YYYYYYY LOD", 11 );
FileCnt = 2;
Ret = cu_fileRecv(COM0, 0, CU_KIND_SPECIAL, &FileCnt,
&FileInfo[0], CU_GRAPH_ON_2, GraphPos );
}else{
memcpy( FileInfo[0].fileName, "XXXXXXX DAT", 11 )
memcpy( FileInfo[1].fileName, "YYYYYYY DAT", 11 )
FileCnt = 2;
Ret = cu_fileSend(COM0, 0, CU_KIND_ALL, &FileCnt,
&FileInfo[0], CU_GRAPH_ON_2, GraphPos );
}
if( Ret == E_OK ){
Ret = CU_ERR_NON;
}else{
cu_readErrStat( COM0, &ComStat, &BiosStat );
Ret = (ComStat & 0xFF);
}
cu_close( COM0 );
cu
_
sto
p
Ke
y
Set
(
CU
_
FNC
_
NON
);
(1)
(2)
(3)
(4)
(5)
(2)
(6)
(7)
(8)
(7)
(8)
(5)
(9)
(
2
)