I've written a program to communicate to a widget connected via a serial
port. I'm certain that I'm missing something so basic, that I can't find
the documentation for it.
I have my widget connected to the one and only serial port on the back of my
laptop. I have a contemporary PnP bios, a recent version of linux.
Questions:
How do I know which comm port is the physical one on the back of the laptop?
Do I need to run setserial or something manually?
Using the code below, I've opened each of the four ports, and get no
errors... although I can't get any widgets to respond
I've read all the serial and modem HOWTOs...and understand about determining
which IRQ, IO PORT, etc... but I don't think its the problem. I want to
know how to specifically communicate with the one on the back of the
laptop. I know I have a built in WinModem, and I can't seem to identify
which port its "using" in order to avoid that port if necessary.
Here's a routine that always returns success (pCommPort is always = 3?!)
int intCommPortOpen(int intCommPort){
printf ("Comm port:\t %s\n", tty_ports[intCommPort]);
pCommPort = open(tty_ports[intCommPort], O_RDWR | O_NOCTTY | O_NDELAY);
if (pCommPort == -1){
printf("Comm port:\t failed opening ttyS%d rc = %d\n",
intCommPort, pCommPort);
return (pCommPort);
}else{
printf("Comm port:\t open %d\n", pCommPort);
fcntl(pCommPort, F_SETFL, 0);
return (0);
}
}
$> setserial
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
Thanks,
TJ
tj <tj@getlostspammer.com> wrote:
# I've written a program to communicate to a widget connected via a serial
# port. I'm certain that I'm missing something so basic, that I can't find
# the documentation for it.
#
# I have my widget connected to the one and only serial port on the back of my
# laptop. I have a contemporary PnP bios, a recent version of linux.
#
# Questions:
# How do I know which comm port is the physical one on the back of the laptop?
If it's not obviously labelled, then I plug the serial ports into things like
a terminal or some other known equipment, and then just trying reading and writing
to each device until I get some kind of response.
# Do I need to run setserial or something manually?
# Using the code below, I've opened each of the four ports, and get no
# errors... although I can't get any widgets to respond
Once the device is properly defined, I dont't have to do anything else
but open the right /dev/* and then configure the device with stty or ioctl
or the equivalent.
You can look up 'man 4 tty' perhaps to get the ioctl functions to change the
speed, parity, and so on. The two ends of a serial cable cannot directly
specify the line characteristics.
--
Derk Gwen http://derkgwen.250free.com/html/index.html
If you plan to shoplift, let us know.
Thanks