www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/30/10:48:27

From: js333 AT anvil DOT gatech DOT edu (Jonathan Swaby)
Newsgroups: comp.os.msdos.djgpp
Subject: reading data from the com port
Date: Tue, 30 May 2000 13:56:02 GMT
Organization: Student Affairs Ga Tech
Lines: 56
Message-ID: <3933bf3a.1039708432@news.gatech.edu>
NNTP-Posting-Host: gooberville.stucen.gatech.edu
X-Trace: news-int.gatech.edu 959694892 25847 130.207.52.70 (30 May 2000 13:54:52 GMT)
X-Complaints-To: usenet AT news DOT gatech DOT edu
NNTP-Posting-Date: 30 May 2000 13:54:52 GMT
X-Newsreader: Forte Free Agent 1.1/32.230
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I have a ADC chip connected to com1: on my computer. I am using
outportb to configure the port. This works fine. The ADC chip spits
out a 7 byte packet. The first byte is 254 and the last is 85. I have
been able to read the bytes, but only one at a time. How do I go about
reading 7 bytes in on shot? I have used inportb to read on character
at a time. That works fine. It prints that data as it comes in. I need
to make sure that I am getting packets that start with 254 and end
with 85. Since the device is constantly sending data, there are
sometimes when the program gets data out of sequence.

Also, I have the program working correctly on my Linux box. The code
will compile fine under djgpp, but I don't know what to use for the
port(MODEMDEVICE).  Below is the code from the linux box to open the
serial port:

void
setup ()
{
  fd = open (MODEMDEVICE, O_RDWR | O_NOCTTY);
  if (fd < 0)
    {
      perror (MODEMDEVICE);
      exit (-1);
    }

  tcgetattr (fd, &oldtio);      /* save current port settings */

  bzero (&newtio, sizeof (newtio));
  newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
 newtio.c_iflag = IGNPAR;
  newtio.c_oflag = 0;

  /* set input mode (non-canonical, no echo,...) */
  newtio.c_lflag = 0;

  newtio.c_cc[VTIME] = 0;       /* inter-character timer unused */
  newtio.c_cc[VMIN] = 7;        /* blocking read until 7 chars
received */

  tcflush (fd, TCIFLUSH);
  tcsetattr (fd, TCSANOW, &newtio);
}


A related question, I have a similar device that is polled. It
responds with data the first 2 times I request it, then yields no
responses after that. Again, I am using outportb and inportb.

Thanks Jonathan Swaby
MODEMDEVICE is /dev/ttyS1 and  BUADRATE=B2400;
Jonathan Swaby
Computer Services Specialist IV
Student Affairs

Georgia Institute 
  Of Technology

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019