Ada GNAT.Serial_Communications behavior on Linux

2019-08-02 18:46发布

I have an Ada program that communicates with an Intellibox Basic(a box that allows you to control trains) that is connected via USB.

Under Windows, I had to install a specific Serial driver (CP210x USB to UART Bridge VCP). With that driver I can communicate perfectly with the box. That means sending commands to the box.

Under Linux I'm communicating via /dev/ttyusb0 and I'm able to get messages from the box, but I can't send commands to the box. Nothing happens. I don't get an error or something.

Is the behavior of GNAT.SerialCommunication differently on Linux ? The program is the same. Do I have to setup certain things to get it to work on Linux ?

For example: A typical 2-byte command has the Command as the first Byte and the CRC check as the second one.

标签: linux usb ada
1条回答
Explosion°爆炸
2楼-- · 2019-08-02 19:22

I had trouble with Serial_Communication at some point, where it turned out to be a problem with hardware-handshake being enabled in Linux. It's hard-coded in g-sercom.adb, look for "CRTSCTS". If your Intellibox does not use hardware handshake, Write() will block.

I believe I solved it by removing the CRTSCTS mask from the flags.

查看更多
登录 后发表回答