Friday, 5 December 2014

Programming and Interfacing the Serial/UART/RS-232 port of a Computer/PC in Windows and Linux Part-2


So here is the linux part of my tutorial on how to interface a serial port. Windows part is here.

To say the truth the programming a serial port is comparatively easier in linux then in windows.

In linux we can open the serial port directly using the terminal emulator. As the terminal emulator has nearly the same settings like a Serial Terminal.

Below is the code for a basic SerialConsole like program which sends any characters typed to the serial port and prints received text in the terminal emulator.



So first we have to override the terminal settings and then apply the settings for the serial port.

You can compile the program directly in linux and run it. Like i wrote above make sure you have proper rights to access the serial port, or better just run the program as root user.

So this is the end of my serial port tutorial.

If you have any questions or suggestions feel free to post a comment.
Unknown An Electronics and Tech Enthusiast

I am a Tech enthusiast who loves to build stuff like new gadgets and tinker around with electronic devices doing some DIY stuff, writing some code and in the process providing something back to the community.

1 comment :

  1. Dear sir,
    I followwed your post and let me tell you that works perfect on a console on my linux mint, I have changed only a line in order to make it work with an arduino uno.
    I am trying to make the same but with codeblocks and xwidgets in order to make a best looking program hmi.
    thank your for your kind information and to share with us.
    Fabio Arias

    ReplyDelete