Serial RS232 + OpenGL (multithread+Serial Comm)

This is a discussion on Serial RS232 + OpenGL (multithread+Serial Comm) within the C Programming forums, part of the General Programming Boards category; Hi, here's my first post I'm to develop a program (Linux) to fetch data from a sensor connected via RS232. ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    2

    Serial RS232 + OpenGL (multithread+Serial Comm)

    Hi, here's my first post

    I'm to develop a program (Linux) to fetch data from a sensor connected via RS232. I need to occasionally send commands and constantly receive data and compute it into a graphical frontend.
    I'm implementing a multithreaded solution, creating one thread only for reading data from sensor via RS232.
    NOTE: The OpenGL frontend is a different binary/application.

    So I have 2 questions:
    1 . How should I call the OpenGL frontend and send it the data? (create another process? How do I share the variables between 2 executables?)
    2 . How do I send an entire string at once to the sensor? (I can't send it byte by byte since the sensor can't distinguish the order of them..)

    Thanks a lot for your time Hope I can help someone out there too

    PS - if anyone wants I'll be glad to send my code, it's about 200 lines..
    Last edited by manatttta; 10-14-2011 at 03:51 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why wouldn't it be able to tell what order you were sending in? Modems on serial ports knew what order things arrived in forever ago.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,437
    Quote Originally Posted by manatttta View Post
    1 . How should I call the OpenGL frontend and send it the data? (create another process? How do I share the variables between 2 executables?)
    There are a number of IPC mechanisms in Linux. I would probably use sockets here. Make the data acquisition software the server, and make the front end the client.
    2 . How do I send an entire string at once to the sensor? (I can't send it byte by byte since the sensor can't distinguish the order of them..)
    Like Quzah said, serial data has always been in order. You can write your own buffering function that takes a whole string instead of a char, and sends it byte by byte for you. If that's in your sending thread, then you can process other data asynchronously while you're busy sending that string.

    PS - if anyone wants I'll be glad to send my code, it's about 200 lines..
    I don't see any need for it right now, since your problems are more general, but if it needs to be posted, just post it in this thread (remember to use code tags!).

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    2
    Thanks a lot for your answers! I'll try to implement sockets, and check if it works sending byte-by-byte.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Serial Communication [RS232]
    By johnny_hush in forum C Programming
    Replies: 12
    Last Post: 01-16-2008, 01:57 AM
  2. RS232 (serial/comm) communication
    By _izua_ in forum C++ Programming
    Replies: 15
    Last Post: 09-06-2007, 09:31 AM
  3. Serial Comm. through a Comm Port - WinXP to PIC
    By MoonlightKnight in forum Networking/Device Communication
    Replies: 5
    Last Post: 10-14-2006, 09:02 PM
  4. Serial comm W32 using CreateFile
    By Foldager in forum Windows Programming
    Replies: 2
    Last Post: 06-30-2003, 01:13 PM
  5. InferRed Serial COMM, cannot write?
    By Xei in forum C++ Programming
    Replies: 3
    Last Post: 01-12-2003, 12:40 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21