Reading from serial port using OpenGL/C

Started by
6 comments, last by J-the-Bear 20 years, 1 month ago
I was wondering if there is a simple way to read from the serial port using OpenGL. My program modifies a graphic depending on info coming from the serial port. I''ve checked the internet but there are hundreds of different methods. I''ve found one which uses handles but I think you have to compule using a win32 console, which I don''t think will work with OpenGL. Any hints or links would be helpful. Thanks.
"If all else fails, lower your standards."
Advertisement
This is a joke, isn''t it? You don''t really think you can acces a serial port using a graphics API.
But anything that works with the Win32 API should do it.
I don''t think J-the-Bear ment to use OpenGL to access the com port I think he means he wants to access the com port from a program that is using opengl.
#define BLOODY_WORK_THIS_TIME;
I don''t think J-the-Bear ment to use OpenGL to access the com port I think he means he wants to access the com port from a program that is also using opengl.
#define BLOODY_WORK_THIS_TIME;
quote:Original post by SauronTheDark
I don't think J-the-Bear ment to use OpenGL to access the com port I think he means he wants to access the com port from a program that is also using opengl.

quote:Original post by J-the-Bear
...read from the serial port using OpenGL...


On a helpful note:
1. OpenGL is a graphics API, in simplistic terms an API is a set a commands that a piece of software calls to do some task without having to worry about how that task is actually accomplished. This means (in the case of OpenGL) that you don't have to know what video card you're using or how it stores data (linear, in planes, etc) just that you use the OpenGL commands to do stuff with it. The Win32 API is another API, it gives apps access to OS controlled resources (That's actually a really lame definition of Win32 but I don't really care).

2. Handles are not limited to console applications, they are used throughout all win32 apps (console and window) to identify system objects such as windows, resources (files, ports) and other stuff.

2. The easyist way (correct me if you know another way that does not use low level hardware commands) to use serial communications in Win32 is using handles so check your Win32 API reference for "CreateFile" as a starting point (I don't know the address of any tutorials on this, anyone that does please post)



Edited by - Michalson on February 19, 2002 10:36:57 AM
Hmm.. yea.

Check up on the win32 api functions:

CreateFile
ReadFile
WriteFile
CloseHandle

To open a com port specify "COM1" or "COM2" and so on for lpFileName parameter in CreateFile.

Thanks for the help I wasn''t sure about the handles working in an application instead of a console. I''ll try using the win32 api. Sauron was right I was hoping to use c or c++ for the port along with my OpenGL. I mentioned this in the title(OpenGL/C).
"If all else fails, lower your standards."
i''m sorry 4 my bad english... and it seems that this is a very late reply... but i hope i can help anyone...

now i''m working on my project that uses opengl to generate 3d graphic, and serial port reader which is used to read data from my gps.

i''m using multithread to accomplish that....
one thread to read serial port, and other to opengl.

from thread that handle serial port, data is loaded into global memory, and the other thread (opengl) reads the global memory...

it wasn''t works so good... one problem i got was i can''t call glutPostRedisplay() from serial port reader thread, so i put glutPostRedisplay() in a function aaa() which is called by glutIdleFunc(aaa).

that''s not a good solution because it used resources that''s unnecesary to do... but until now, i get no answer to solve this problem.

i run this project without any problem on my laptop... my laptop can run for 1.5 hours without power cord plugged (only with the battery).... when i tested this program on the car (run only by the battery''s power), only about 30-40 minutes my battery run from full to empty... then at home, i see that my program used about 99% of proccessor..... it''s a very shocking fact, because at idle, it takes only 10 to 15%.

This topic is closed to new replies.

Advertisement