Thread: com port, graphing, win32

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    7

    com port, graphing, win32

    Hi,
    I am working on a project that needs me to grab information from a com port (the info will be in decimal form, not binary) and put those numbers into a graph. BTW, This is for windows. I want the program to have a gui i.e. a "start" button when the information from the com port is needed. Does anyone have any suggestions on how to go about doing this. I have never grabbed information from a com port before... Thank you.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    You can get a handle to the various I/O ports with the CreateFile() API routine, look it up in the help, particulaly the section dealing with "communication resources".

    Once you have a handle, you can use any of the handle based I/O routines to read and write the port.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    7
    Thank you adrian.
    I checked google and found help on how to open the port then write from it. I hink i understand what to do. but still have questions.
    After i get that data and write it to a file or whatever, then i will be able to make a graph out of it? BTW, the information comming in is"speed" and "force" so i need these decimal numbers to be put into a graph. Is that difficult to do?

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> Is that difficult to do?

    Depends, for me, no! I don't know what standard of programming you are at, but a basic X-Y scatter plot or similar is pretty straight forward.

    Describe in a little more detail how you wish the results to appear, it's a bit vague at the moment. Whatever, I'm sure we'll be able to do it.

    The attached file is just about as basic a Windows program as you can make. Have a look at it, and possibly lookup SetPixel() for plotting points, (although they will be very small, and probably not the best solution - but it gives you some idea of the task).
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Hmmm, try again!
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    7
    well, basically i want the data to show up in a line graph with two different color lines. x=force and y=speed (the two variables needed) that is all i need really. I just want to be able to save the graph and to be able to print it off on paper.

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Look at PolyLine(), CreateCompatibleDC() CreateCompatibleBitmap(), SelectObject() , CreateSolidBrush(), TextOut() ect

    convert the floats to ints with a factor (ie *100 for two decimal places).

    Will need to calculate a scale based on the area you have on screen (to draw in).
    remember y increases as you go down the screen

    or

    Set a world transform (that is, arbitary set the axis and scale on the HDC based on the range of values you have to graph)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  8. #8
    Registered User
    Join Date
    Jul 2003
    Posts
    7
    Thanks Novacain and Adrian.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sending streams over serial port in win32
    By deian in forum C Programming
    Replies: 2
    Last Post: 07-13-2009, 12:01 PM
  2. Concurrent chat, Sockets
    By jakemott in forum Linux Programming
    Replies: 6
    Last Post: 11-29-2008, 05:41 PM
  3. FTP program
    By jakemott in forum Linux Programming
    Replies: 14
    Last Post: 10-06-2008, 01:58 PM
  4. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  5. Segmentation Fault - Trying to access parallel port
    By tvsinesperanto in forum C Programming
    Replies: 3
    Last Post: 05-24-2006, 03:28 AM