Programming 版 (精华区)

发信人: Mice (鼠儿), 信区: Programming
标  题: DOS下的串口通信编程----(6)
发信站: 紫丁香 (Mon Sep 15 16:05:37 1997)

//一个应用例子
#include "serial.h"
#include "plc.h"
#include <conio.h>
#include <stdio.h>

void main()
{
        int i;
        unsigned char rcv;
        unsigned char *pointer;
        PLC plc(0);
        textcolor(YELLOW);
        textbackground(BLUE);
        clrscr();
        plc.write("h990201","99");
        if(plc.error()==TIMEOUT) {
              printf("Write error!");
                return;
        }
        pointer=plc.read("g990201");
        i=0;
        if(pointer!=NULL){
                printf("<RTX>\n"); i++;
                while(pointer[i]!=EOT) {
                        printf("%c%c ",pointer[i],pointer[i+1]);
                        i+=2;
                }
                printf("\n<EOT>\n"); i++;
                printf("BCC code: %c%c",pointer[i],pointer[i+1]);
        } else {
                printf("Receive error!");
        }
}

//注意,此plc为LG系列

--




       我是一只好老鼠

※ 来源:.紫丁香 pclinux.hit.edu.cn.[FROM: 202.118.226.74]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.144毫秒