发表于:2006-06-08 16:12:00
楼主
小弟由于工作需要,现要把原WINDOWS平台开发的MODBUS通讯移值到LINUX平台.但不知怎么搞通讯老是不正常,请各位高手帮我看看.
通讯参数:9600,8,1,NONE
由于是9600,8,1,NONE;因此在MODBUS通讯上,每次指令发送间隔大约4毫秒;在WINDOWS平台上一切正常,没有发送和接收上的碰撞.但在LINUX平台却有问题,把发送间隔调整为1秒,一切就正常了.我觉得没道理呀,怎么会这样......????
//Linux COM Operation
bool InitialCom(int iComPort,int baud,int parity,int bit_cnt,int stop_bit,int timeouts,int *fdp)
{
int status;
int fd;
struct termios options;
status = lux_open(iComPort);
if ( status == -1 )
return false;
else
fd = status;
switch(baud)
{
case 50:
baud = B50;
break;
case 75:
baud = B75;
break;
case 110:
baud = B110;
break;
case 134:
baud = B134;
break;
case 150:
baud = B150;
break;
case 300:
baud = B300;
break;
case 600:
baud = B600;
break;
case 1200:
baud = B1200;
break;
case 1800:
baud = B1800;
break;
case 2400:
baud = B2400;
break;
case 4800:
baud = B4800;
break;
case 9600:
baud = B9600;
break;
case 19200:
baud = B19200;
break;
case 38400:
baud = B38400;
break;
case 57600:
baud = B57600;
break;
case 115200:
baud = B115200;
break;
default:
baud = B9600;
break;
}