Cover V04, I05
Article
Figure 1
Figure 2
Figure 3
Listing 1
Listing 2
Listing 3
Listing 4
Sidebar 1

sep95.tar


Listing 3: Canonical mode processing on a TTY line

Include Section:
1.  #include <termio.h>

Definition Section:
2.  struct termio NewParms;
3.  int RdChars, ImbsPort;
4.  union imbs {
struct {
char Stx;
char Ttype;
char SeqNum[2];
char BcNum[7];
char Wgt[4];
char Etx;
char Filler;
} Imbs;
char Buf[17];
} Imbs;

Coding Section:

5.  if((ImbsPort = open("/dev/tty08", \
O_RDWR | O_NDELAY)) < 0)
printf("Error opening Scale Input Port!\n");
6.   ioctl(ImbsPort, TCGETA, &NewParms);
7.   NewParms.c_cflag |= CLOCAL;
8.  NewParms.c_cflag |= CS7;
9.  NewParms.c_cflag |= CSTOPB;
10. NewParms.c_lflag |= ICANON;
11. NewParms.c_lflag &= ~ECHO;
12. NewParms.c_lflag &= ~ECHONL;
13. NewParms.c_iflag &= ~IXON;
14. NewParms.c_cflag |= B9600;
15. NewParms.c_cflag |= PARENB;
16. ioctl(ImbsPort, TCSETAF, &NewParms);
...

Coding section to read the tty line from the DOS PC:

17. RdChars = 0;
18. RdChars = read(ImbsPort, &Imbs, sizeof(Imbs));