I am trying to communicate with a device over a RS-485 half duplex serial line. When I send a command to the device, it processes the command and replies immediately after processing. The problem is I have to turn my RS-485 chip into receive mode immediately after sending the command in order to receive the reply of the device. But because my write function of the UART is a non-blocking IO operation I have no way of knowing when to turn my RS-485 chip into receive mode.
How can I do a blocking write operation into the UART that the function will not exit unless all of the bytes are actually sent over the serial line?
What is your hardware platform? I have solved that problem before (atmel AT91SAM9260) by configuring the hardware to automatically set the RTS signal. That is your best bet unless you modify the serial drivers in the kernel (and sometimes not even doing that you can do it)
Related
I'm currently in a situation that my SoC will be connected via its I2C bus through a I2C-to-UART converter MAX3107 to the UART port of a microprocessor.
Although the communication between the two shouldn't be an issue, the part were the Soc should update the firmware of the microprocessor has to be done with the Y-Modem file transfer protocol.
Although a question is pending at the manufacturer, I still wanted to check here:
Would this even be possible
The SoC runs Linux, is this depending on the MAX3107 driver
Does this concern the I2C bus or is only the UART driver and bus interesting.
https://datasheets.maximintegrated.com/en/ds/MAX3107.pdf
I used the SC16IS750 instead with the Linux kernel driver.
Sending a file via Y-Modem doesn't seem to be a problem. I tried both Minicom and TeraTerm to send a file and it works. The receiver responds is just 1 character each time before sending a part of the file. If the responds would have been more than 64-byte at a time (instead of the one character) this would have been a problem, because the FIFO first needs to be read and cleared before another sting can be received.
We're accessing an FPGA device via the Linux UIO device infrastructure. Under this model, we receive interrupts from the FPGA by poll(2)ing the device node /dev/uio0.
We'd like to make sure that we don't miss any interrupts. Hence we need a way to notify clients of the class encapsulating the device file descriptor when our polling thread is ready waiting in the poll(2) system call, so that we can be sure that we're only telling the FPGA to start generating interrupts when we're actually waiting for them.
Do you know of any way to achieve that?
Thanks,
Damian
I want to know whether Linux kernel device driver of serial port device, e.g. /dev/tty1, /dev/tty2, support poll() operation?
Or tell me where is the kernel source code of serial port device?
In my case, some sensors will send data to ARM CPU via serial port each second. And I think one way is to use a timer for periodically read from the serial port. Another way should use poll(), read it when data is ready.
Unless your serial port is a special case, using poll() or select() would seamlessly work.
If your serial port was controlled via USB, you would have to take care about what happens if the USB to serial is disconnected, but this does not seem to be the case for you.
I'm having an embedded linux device. I'm using ttyO2 as my console.
However, at the same time my MCU need to perform RS232 communicate with a device through ttyO2.
Now lets say if the MCU and the device are communicating, and I type some characters in the console terminal, or there runs another thread that will invoke function printf() , will that conflicts with the 232 communication? is the printf() outputting to the ttyO2?
Thanks
I'm using ttyO2 as my console.
so you configured serial port as console, printf() output will be redirected to console. i.e serial port.
If your board is communicating over RS232 with an external device, then then board and the device are connected with a serial cable. How can you also connect the the serial terminal?
In any case, using the same serial port as console and as a communication port is a bad idea, because there are a lot of things that can be printed: the console I/O, the kernel debug, other programs output to stdout and so on.... Do you think you can have a stable communication with all that "junk" on the wire?
I'm using a linux OS and was wondering if there were any file descriptors I could poll/select which would trigger when data was waiting to be read from a usb device. I am also using the libusb library and have yet to find file descriptors which I can use.
Use libusb's polling functions to hook its file descriptors into your event loop. select will wake up whenever there's activity that libusb will need to handle, which includes but probably is not limited to data being available for reading.
No, USB devices are not always "stream" devices, so reading from a file descriptor doesn't always make sense. However, if your USB device provides a serial port driver, you can listen for incoming data on the serial port device (just like any other serial port handled by your OS).