2 lqjjackie lqjjackie 于 2014.06.12 17:04 提问

linux一段串口初始化的程序请大神解释

//初始化串口
#ifdef linux
memset(tmp,0,128);
if (commtype==0)
sprintf(tmp, "stty </dev/%s%d clocal cread -icanon -echo -echoe -opost -istrip min 0 time 5",
DEVNAME,TCP_IP_Start - ProjectNo + SER_Start);//,1200 , "even", 1, 8);
else sprintf(tmp, "stty </dev/%s%d clocal cread -icanon -echo -echoe -opost -istrip min 0 time 5",
DEV3G,0);

    syscmd(tmp);
    delay(100);
    memset(tmp,0,128);
    if (commtype==0)
        sprintf(tmp, "stty </dev/%s%d -hupcl -isig -iexten -echok -echoke -echoctl -icrnl -onlcr -ixon",
            _DEVNAME_,TCP_IP_Start - ProjectNo + SER_Start);//,1200 , "even", 1, 8);
    else sprintf(tmp, "stty </dev/%s%d -hupcl -isig -iexten -echok -echoke -echoctl -icrnl -onlcr -ixon",
            _DEV3G_,0);
    syscmd(tmp);
    delay(100);

    memset(tmp,0,128);
    if (commtype==0)
        sprintf((char*)tmp,
            "stty </dev/%s%d 9600 cs8 -parenb -cstopb",
            _DEVNAME_,TCP_IP_Start - ProjectNo - SER_Start);
    else sprintf((char*)tmp,
            "stty </dev/%s%d 9600 cs8 -parenb -cstopb",
            _DEV3G_,0);
    syscmd(tmp);
    delay(1000);
    #else
    memset(tmp,0,128);
    sprintf((char*)tmp,
            "stty </dev/%s%d baud=9600 par=none stopb=1 bits=8",
            _DEVNAME_,TCP_IP_Start - ProjectNo - SER_Start);
    syscmd(tmp);
    delay(1000);
    #endif
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!