Using the com port on the iMX53

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using the com port on the iMX53

Jump to solution
3,917 Views
leonardfairclot
Contributor II

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);

Labels (1)
Tags (3)
0 Kudos
1 Solution
3,299 Views
weidong_sun
NXP TechSupport
NXP TechSupport

If you are using ubuntu, you can use root account like this :

#sudo bash

Then input lucid .

weidong

View solution in original post

0 Kudos
26 Replies
2,813 Views
leonardfairclot
Contributor II

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

0 Kudos
2,813 Views
weidong_sun
NXP TechSupport
NXP TechSupport

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

0 Kudos
2,813 Views
leonardfairclot
Contributor II

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

0 Kudos
2,813 Views
weidong_sun
NXP TechSupport
NXP TechSupport

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

0 Kudos
2,813 Views
leonardfairclot
Contributor II

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 

0 Kudos
2,813 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,Leonard,

    you please check all uart devices in path /dev/:

# ls -l /dev/ttymxc*

to confirm if uart devices have been driven.

Regards,

Weidong

0 Kudos
2,813 Views
leonardfairclot
Contributor II

Nothing is found.  How do I add uart devices\drivers?

0 Kudos
2,813 Views
leonardfairclot
Contributor II

I have tty0-63 and ttys0-31.  No ttymxc*.

0 Kudos
2,813 Views
leonardfairclot
Contributor II

Sorry, I was looking on my development PC, I found them on the development board. I have "ttymxc0-4" on the iMX53.

0 Kudos
2,813 Views
leonardfairclot
Contributor II

The permission on ttymxc0 is "crw-------" where as all the others are "crw-rw----"  could this be the issue?  Chmod will not all me to change the permission.  What do you think?

0 Kudos
2,813 Views
weidong_sun
NXP TechSupport
NXP TechSupport

don't use ttymxc0. use others please ! For example , use UART4:

#chmod 777 /dev/ttymxc4

Then run your program.

Weidong

0 Kudos
2,813 Views
leonardfairclot
Contributor II

I'm logged in as lucid and don't have permission to chmod this file.  How can I get around that?  I don't believe there is a root on the iMX53, right?

0 Kudos
2,813 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Are you using ubuntu system on mx53QSB ?

weidong

0 Kudos
3,300 Views
weidong_sun
NXP TechSupport
NXP TechSupport

If you are using ubuntu, you can use root account like this :

#sudo bash

Then input lucid .

weidong

0 Kudos
2,813 Views
leonardfairclot
Contributor II

Thanks for your help tonight.

I should be working at it again Sunday night.

Leonard

0 Kudos
2,816 Views
leonardfairclot
Contributor II

Nice!  Thanks  I got past the first error now I'm getting a segmentation fault..  Let me look at that.

Thanks again

Leonard

0 Kudos
2,816 Views
leonardfairclot
Contributor II

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

0 Kudos
2,816 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Ok, you can run your program on board, and check if UART has been opened successfully.

Regards,

Weidong

0 Kudos
2,816 Views
Yuri
NXP Employee
NXP Employee

In the same time there are no other UART connectors on the i.MX53QSB (except one for UART1).
Basically it is possible to use console.

0 Kudos
2,816 Views
leonardfairclot
Contributor II

That's good news, is there something I need to run before trying to open a port within a program.  What does "minicom" do?

0 Kudos