[問題] Linux RS-232程式設計~
各位大大好,我想請問一下就是說
我現在要用RS-232來做一個資料的傳送,
然而我預計要傳送29筆資料出去,但是接收端卻只能接收前8筆資料或前9筆資料,
之後的資料就都不見了,所以想請問這大概會是哪裡有問題,謝謝!
收資料方面利用終端機收。
以下是我的傳送端程式碼,開發環境是QT撰寫。
int fd,res=0;
struct termios oldtio,newtio;
int s1[29]= {0x01,0x10,0x17,0x70,0x0,0xa,0x14,0x0,0x81,0x0,0x81,0x0,
0x83,0x0,0x99,0x0,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0xff,0xff,
0xff,0xff,0xb3,0xdd};
char s2[29]={0};
fd = open (MODEMDEVICE, O_RDWR|O_NOCTTY);
tcgetattr (fd, &oldtio);
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BAUDRATE | CS8 | CLOCAL |CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &newtio);
for (int i=0;i<29;i++)
{
s2[i]=s1[i];
}
res=write(fd, s2 ,29);
tcsetattr(fd, TCSANOW, &oldtio);
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.182.35
→
10/17 21:39, , 1F
10/17 21:39, 1F
→
10/17 22:08, , 2F
10/17 22:08, 2F
→
10/17 22:12, , 3F
10/17 22:12, 3F
→
10/17 22:12, , 4F
10/17 22:12, 4F
→
10/17 22:13, , 5F
10/17 22:13, 5F
推
10/17 22:16, , 6F
10/17 22:16, 6F
→
10/17 22:43, , 7F
10/17 22:43, 7F
→
10/17 22:44, , 8F
10/17 22:44, 8F
→
10/17 22:45, , 9F
10/17 22:45, 9F
→
10/17 22:48, , 10F
10/17 22:48, 10F
→
10/17 23:01, , 11F
10/17 23:01, 11F
→
10/17 23:07, , 12F
10/17 23:07, 12F
→
10/18 01:11, , 13F
10/18 01:11, 13F
→
10/19 18:10, , 14F
10/19 18:10, 14F
→
10/19 18:11, , 15F
10/19 18:11, 15F