3585
今日の組み込み
SDへの書き込み検証(その1)
以下のソースで試験を行ってみた。
--------
int main(int argc, char **argv)
{
unsigned char cbuf[3],data;
unsigned int n;
int hSdfile;
hSdfile = open(argv[1],OptWrite);
if ( hSdfile == -1 ) {
printf("File openNG [%s]\r\n",argv[1]);
return 0;
}
printf("File openOK [%s]\r\n",argv[1]);
while(1) {
while( n == 0 ) {
n = read(0, cbuf, 3);
}
n = 0;
data = cbuf[0];
write(hSdfile,&data,1);
if(data == '@') break;
}
close(hSdfile);
return 1;
}
--------
SCIは標準の物を使用して115.2kbpsで受信しています。
実行してみました。
--------
MES >com2sd.exe /ram0/rgps.txt
File openOK [/ram0/rgps.txt]
MES >type rgps.txt
$R,255,,,,2056,92$PC540A1N9AP25GP0
$R,265,,,91,1,065$R,2608A,,,S,620$R,2658$P2,1G3320$GM15.,0,1GP,10,7$R,275,16NG$7
1195$R,270,,
,44
,5,0$R,275,0,0,056,.0$R,280,9*01,170.0$R,285,,*E31*1170$PC545A,,2,V5943,$R,285,2
22,V50,3,$R,290.
A4,2V,650$R,2953*P92,12,N.$R,290,012,V50,3,$R,2953,$2,773,,.$R,200,,
3,1,,,0$R,205,0,0,,1,02A$R,200,0A,2,,,4,0$R,205,0,334,0G6.0$R,210,7301,1,93P$R,2
15,1,9AP0,1L$R,210,9A1A,,,,.P$R,215,0,8,,,7985$PC550A,22,V5014A$R,22545G4,1914D$
R,22045G4,,S284,$R,2253,G,,1,025$R,230.1G4,0G2030$R,235,,210,52,15$R,230,,,11P,1
,G6$R,2355,*E31*10,7$R,240,0,9AS2933P$R,245,9*E3110,32$R,2403,4,156932$R,2454*
3,,120.,$R,250,..8
D413P2*$R,255,73,,,17921$R,2505,$2,,$1,15$R,2553*G2,1$001,$R,260,7332,12061$R,26
5,,
3,4
,791$R,260,1N9AP021G
$R,265,,241,,,922$R,2708A,,110,55$R,275,1,2,V5014P$R,270.6P9,1,025$R,275,1,0
,23GA8$R,2806
G5,,S,0.0$R,28566P1011248,$R,280.0P10771,2A$R,285,0*,,77,,1,$R,29046P47112,1,$R,
295,9A.,313,3,$R,290,73.2,13,3,$R,295,0,3,1,,791$R,200,9*E3,12,26$R,205,95,$0,,8
1$R,2006
A,,8V33,0$R,205,93NG$7,,22$R,21045G5,,S,320$GM16.,4,1GP0,,L
$R,210,,
,44
3,.,$R,215,734,1,,720$R,2206
,5,05,039@MES >
--------
とデータ取りこぼしすぎです。
本当ならこんな感じになるはず。
--------
$GPVTG,115.39,T,,M,0.464,N,0.859,K,A*30
$GPGGA,152925.50,3534.72850,N,13921.16989,E,1,5,3.19,131.9,M,39.3,M,,*62
$GPGSA,A,3,02,13,12,23,04,,,,,,,,3.81,3.19,2.09*0E
$GPGSV,3,1,10,02,42,312,25,17,39,170,,13,54,076,36,25,12,113,*73
$GPGSV,3,2,10,27,07,131,,05,03,305,,20,03,059,,12,11,289,24*73
$GPGSV,3,3,10,23,30,048,43,04,71,013,29*7A
$GPGLL,3534.72850,N,13921.16989,E,152925.50,A,A*6A
$GPZDA,152925.50,10,09,2007,00,00*66
$GPRMC,152925.75,A,3534.72852,N,13921.16984,E,0.261,94.92,100907,,,A*59
$GPVTG,94.92,T,,M,0.261,N,0.483,K,A*01
$GPGGA,152925.75,3534.72852,N,13921.16984,E,1,5,3.18,131.9,M,39.3,M,,*6B
$GPGSA,A,3,02,13,12,23,04,,,,,,,,3.81,3.18,2.09*0F
$GPGSV,3,1,10,02,42,312,25,17,39,170,,13,54,076,37,25,12,113,*72
$GPGSV,3,2,10,27,07,131,,05,03,305,,20,03,059,,12,11,289,24*73
$GPGSV,3,3,10,23,30,048,44,04,71,013,29*7D
$GPGLL,3534.72852,N,13921.16984,E,152925.75,A,A*62
$GPZDA,152925.75,10,09,2007,00,00*61
$GPRMC,152926.00,A,3534.72853,N,13921.16981,E,0.288,107.71,100907,,,A*6D
$GPVTG,107.71,T,,M,0.288,N,0.534,K,A*3D
$GPGGA,152926.00,3534.72853,N,13921.16981,E,1,5,3.18,131.9,M,39.3,M,,*6E
--------
やっぱり、1バイト毎じゃダメですかね。。。
07/09/11