Thread: RS232 serial port library for Linux and Windows

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    15

    Lightbulb RS232 serial port library for Linux and Windows

    If you intend to write a GPL-licensed, opensource and multiplatform program in C or C++ and you want to use the serial port, look here:

    RS-232 for Linux and WIN32

    With this library, you can use GCC on Linux and MinGW on windows to access the serial
    port without the need to make any changes in your sourcecode.

    Regards.

  2. #2
    Registered User yann's Avatar
    Join Date
    Sep 2009
    Location
    Zagreb, Croatia
    Posts
    186
    woooooooow, thanks man!
    Arduino rocks!

  3. #3
    Registered User yann's Avatar
    Join Date
    Sep 2009
    Location
    Zagreb, Croatia
    Posts
    186
    is there anything like this for the USB port?
    Arduino rocks!

  4. #4
    Registered User yann's Avatar
    Join Date
    Sep 2009
    Location
    Zagreb, Croatia
    Posts
    186
    But....how to install the library?
    Arduino rocks!

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    15
    Quote Originally Posted by yann View Post
    But....how to install the library?
    Put the two files in the directory where your other C files are.
    Put the following define in the headerfile of the module from
    where you want to use the RS-232 functions:

    #include "rs232.h"

    Don't forget to tell your compiler that it has to compile and link
    the rs232.c file. For example:

    gcc main.c rs232.c -o myprogramname

  6. #6
    Registered User yann's Avatar
    Join Date
    Sep 2009
    Location
    Zagreb, Croatia
    Posts
    186
    Ok thanks, is there anything like this for USB-port?
    Arduino rocks!

  7. #7
    Registered User
    Join Date
    Sep 2009
    Posts
    15
    Quote Originally Posted by yann View Post
    Ok thanks, is there anything like this for USB-port?
    You can use this library for USB-devices as well in case your USB-device uses a FTDI-chip
    for USB-connection in combination with a VCP-driver (Virtual ComPort).
    Linux has this USB-VCP-driver already built-in. For windows you need to download
    a free driver from the FTDI website.

    For more info about VCP-drivers for USB-devices, visit:

    Virtual COM Port Drivers

    Virtual COM port (VCP) drivers cause the USB device to appear as an additional COM port available to the PC. Application software can access the USB device in the same way as it would access a standard COM port.

  8. #8
    Registered User yann's Avatar
    Join Date
    Sep 2009
    Location
    Zagreb, Croatia
    Posts
    186
    Thanks man...can you give me some code examples for USB?
    Arduino rocks!

  9. #9
    Registered User
    Join Date
    Sep 2009
    Posts
    15
    Quote Originally Posted by yann View Post
    Thanks man...can you give me some code examples for USB?
    There is no difference with a serial port because the VCP-drivers emulates a serial port.
    Except for that you have to open /dev/ttyUSB0 instead of /dev/ttyS0.

    Virtual COM port (VCP) drivers cause the USB device to appear as an additional COM port available to the PC.
    Application software can access the USB device in the same way as it would access a standard COM port.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. serial port control
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 08-09-2002, 06:44 PM
  2. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  3. Need help or info about serial port communication
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 01-08-2002, 01:48 PM
  4. serial port still wont work
    By alcoholic in forum C++ Programming
    Replies: 6
    Last Post: 10-31-2001, 12:51 PM
  5. sendng bytes to a serial port need help
    By alcoholic in forum C++ Programming
    Replies: 1
    Last Post: 10-28-2001, 11:17 AM