Link to home
Start Free TrialLog in
Avatar of zhao040597
zhao040597

asked on

port control in watcom c/c++ under QNX

I am trying to modify a program written in Watcom c/c++ under QNX 4. I want to let it communicate with another computer using serial port. So far I have just found functions like outp(), outw() to access the hardware,
but to communicate successfully one needs to specify the Baud rate, number of data bits, etc. Is there any function in Watcom c/c++ to do that? I couldn`t find the version of which I am using, I just know its accompanied manuals
were written in 1993. Thanks in advance
Avatar of icd
icd

Specifying baud rate etc is a function of the serial device. This device can be programmed by writing to its output control ports using outp() and outw(). All you need to know is the port number and the specification for the device.


ASKER CERTIFIED SOLUTION
Avatar of claudeb
claudeb

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zhao040597

ASKER

Thanks for your answer.

But first, is this written in Watcom c/c++?
Second, what header file should I include?
Third, the serial ports of the two computers are 9-pin, and I connected them in this way:
        a            b
       2(RD)-----------3(TD)
       3(TD)-----------2(RD)
       5(Ground)-------5(Ground)
       4(DTR)          4(DTR)
       |               |
       |               |
       6(DSR)          6(DSR)
       7(RTS)          7(RTS)
       |               |
       |               |
       8(CTS)          8(CTS)

In this way, I have no problem to use Qbasic to communicate with each other(send and receive), but do you think your program will work in this way of connection? (Both computers are PC)

Since I just have some basic knowledge of c and totally unfamiliar with QNX, I want to make sure it should works before I look through a whole bunch of manuals.

Thank you.
Yes, it was written under QNX using Watcom C 10.6.  The header files you'll need are:

#include <sys/dev.h>
#include <sys/kernel.h>
#include <sys/types.h>
#include <sys/qioctl.h>

I think those should do.  As far as your cable goes, it will work ONLY if you have XON/XOFF flow control.  You need a proper null modem cable which (I think) should be:

2(RX)-----3(TX)
3(TX)-----2(RX)
4(DTR)----6(DSR)
6(DSR)----4(DTR)
7(RTS)----8(CTS)
8(CTS)----7(RTS)
5(GND)----5(GND)

Hope this helps!