Has anyone created an application that opens the com port and listens to incoming messages and sends a response?
I'm writing in C and I believe that the "stdio.h" should have everything I need. When I try to open the port I get error messages. It doesn't seem to like the parameters:
int portnum
portnum = open("dev/ttys0", O_RDWR | O_NOCITY | O_NDELAY);
已解决! 转到解答。
If you are using ubuntu, you can use root account like this :
#sudo bash
Then input lucid .
weidong
Weidong Sun
Thanks, this was very helpful. Just a question for you. Is there a reason you use "ttymxc1"? I'm using the quick start board iMX53 and it only has one serial port on it. I was trying "ttymxc0", just curious if you knew what I should use for this board.
Thanks
Leonard
Hello,Leonard,
you please pay attention to ttymxc0 on mx53QSB, this is UART1 hardware, on this board, UART1 is used by console. when system startup , all messages ouput to console via this port. So you had better not use it to communicate with other device.
Regards,
Weidong
Good point Wiedong, I need a serial port do you have any other suggestions? I could go USB to Serial but I really wanted to avoid that. What port are you using and did you have to configure the serial port before you were able to run your program? i was just reading about "minicom".
Thanks
Leonard
Hello,Leonard,
UART4 & UART5 can be iomuxed by CSI0 port. On i.mx53QSB , by default these pins are used for carmera and connected to J13.
You may consider how to connect them outside and do UART test. In addtion, Don't forget to adjust BSP file: add these pins to mx53_loco.c.
You can get iomux pins mapping by mcimx53rm.pdf. please refer to it !
CSI0_DAT12--->UART4_TXD
CSI0_DAT13--->UART4_RXD
CSI0_DAT14--->UART5_TXD
CSI0_DAT15--->UART5_RXD
<Note: UART4--->ttymxc3; UART5--->ttymxc4, the level of these 2 ports are 1.8V >
Regards,
Weidong
Thanks Weidong
I'll try that, not tonight. When i run your app, I get "open uart error, please confirm if this device exist"I tried "ttymxc0" and "ttymxc1" with the same results. The open routine is returning a "-1", is this an error that can be looked up?
Thanks
Leonard
Any idea as to why I'm getting a segmentation fault? I out a few print statements to see where it may be crashing and not luck so far. I'm calling a procedure to open the port, then when I return I check to see if there is anything in the buffer?
Thanks