Serial ports - communication with devices

  • Thread starter Thread starter moffet
  • Start date Start date
M

moffet

Guest
Hi, I have a relay card that is controlled via RS232.
My computer has 4 COM ports on the mainboard.

I'm trying to send raw bytes to the card through:
printf "\6\0\1\7" > /dev/cuau0
and this command works only once after reboot (relay is switched on the card). When I'm invoking it for the 2nd time, the command blocks (waits for input?) and nothing happens, until I press CTRL+C.

Has it something to do with /etc/ttys and getty interfering with the communication?
I just want to use COM ports for connecting with custom devices, not for old school console logins.

Please help. Thanks.
 
That it works only once suggests a flow control difference, like one device is expecting hardware flow control (RTS/CTS), but the other end is using software flow control.

On the other hand, that it works at all suggests that the RX and TX lines are connected correctly in the cable and the baud rate is correct.
 
The baud rate is correct - 19200. The cable is also OK. Card works beautifully on this cable in Windows 7.

Today another weird thing happened. I've connected USB-RS232 adapter on Prolific chipset, so FreeBSD created another serial port: /dev/cuaU0.

When I invoked: printf "\6\0\1\7" > /dev/cuaU0 , device was disconnected, and reconnected again in the system. And this happens every time I do this. Adapter works fine in Windows 7.

I have to start live CD on this hardware and then see if serial ports work.
 
I've just booted FreeBSD 9.1 i386 live CD from memory stick on this hardware.
The result is the same as in installed version. After sending few bytes to /dev/cuau0 (hardware COM port on the mainboard), the second printf stucks. Waiting to open port or something like that. I have to press CTRL+C to go back to the prompt.

But I've also booted FreeBSD 10.1 i386 live CD, and everything works!! I can invoke as many printf redirected to serial port as I want, and the relay board switches appropriate relay.

So something was changed from FreeBSD 9.1 to 10.1 that is related to serial ports, UART, etc.
 
Back
Top