[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

asynchronous I/O in SCO/UNIX

Posted on 1998-11-22
2
Medium Priority
?
391 Views
Last Modified: 2013-12-05
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    I have been developing a program to communicate with a IC Reader Device via serial port. What i really want is it
can write & read any characters range from 0x00 to 0xff in
the very raw mode.
    But when it read from the Reader, sometimes it missed some characters. After comparing
with the characters it should receive, i found the missing characters were those behind the 0x11
character, which was stop_character (Ctrl+q). But it does not always like this. In ordinary it
works right way.
( .
1. When right, the data i receive:
    10 00 00 14 05 1a 3b 2f 00 00 48 44 4d 11 98 37 01 40 00 01 f3 00 90 00 d7
2. When error, the data i receive:
                                                                         98 37 01 40 00 01 f3 00 90 00 d7
 * i read & write a character everytime.
)

I doubt that there is a mistake in the communication mode somehow . But i am not sure of the cause.


Thank you for reply in advance.


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* SCO/unix */
//The following is my codes:
#include <termio.h>

int srl_fd;

set_serial_mode()
{
 struct termio  tiopck, tiopck_;

 if ( (srl_fd = open("/dev/tty1a", O_RW)) < 0 )
  return -1;

     ioctl(srl_fd, TCGETA, &tiopck );
     tiopck_ = tiopck;

 tiopck_.c_iflag = 0;
 tiopck_.c_oflag = 0;
//9600, 8bit, no parity
 tiopck_.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
 tiopck_.c_lflag &= ~(ICANON | ECHO | ISIG);
 tiopck_.c_line = 0;
 memset( tiopck_.c_cc,  0x00 , NCC );
 tiopck_.c_cc[VMIN] = 1;
 tiopck_.c_cc[VTIME] = 0;
       
 if ( ioctl(srl_fd, TCSETAW, &tiopck_ ) < 0 )
  return -1;

 return 0;
}


0
Comment
Question by:xxz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
BigRat earned 200 total points
ID: 2008004
You are losing characters becase of the interpretation of 0x11 which is XOFF. You must switch off XON/XOFF control on that port. SAince I am at home with a cold I can't tell you which parameter to set (if it is not obvious from the manual). So if you can't switch off XON/XOFF reject this answer and when I get back to work tomorrow or the day after I'll look in the manual for you.
0
 

Author Comment

by:xxz
ID: 2008005
Bigbat,
     Thank you for your reply. In fact in my codes, the statement "  tiopck_.c_iflag = 0; "  has switch off the XON/XOFF.
     I have solved this problem by setting " tiopck_.c_cc[VMIN] = read_num; " . I used to read  one byte each time (" tiopck_.c_cc[VMIN] = 1; "), and it worked very well in previous condition. But this time, i read all the bytes sent out by Reader Device, so I have to change read_num each time when  i read from serial port.
     I wonder the differences between " tiopck_.c_cc[VMIN] = read_num; " and "tiopck_.c_cc[VMIN] = 1; ".So far,  i am not understand why.
     
                                  * read_num is the number of bytes which Reader Device  send out.
    Good Health!
                                                                                                                   Xu XiaoZhou
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question