serialport.h - missing something simple im sure - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

serialport.h - missing something simple im sure

coyoteboycoyoteboy Posts: 45Member
I'm trying to use serialport.h MFC wrapper to send data to COM1. Where do I put the
CSerialport port;
port.Open(bla bla bla)

to ensure that the port is opened the instant the program is initiated, and only closes when the program exits? At the moment I'm stuck trying to figure out the scopes of each function. If I put the declaration in the message handler it works fine but i dont want the added time taken to open the port and close it again every time, plus I may have a different thread recieving at the same time or very shortly after. Where ever I put it it either throws compile-time errors about 'port' not existing or it closes it immediately after sending. Its simple in proceedural - you just lob the open in at the top and the close at the end, in a GUI i'm stuck :) I'd post the full code but I think people would get mad - its a long program.

James

Comments

  • dwccgcdwccgc Posts: 576Member
    Where did you get this serialport.h file -- it is not a part of MFC.

    Check out this site; you might find your answer here.
    http://www.codeguru.com/network/CSerialPort.html


    : I'm trying to use serialport.h MFC wrapper to send data to COM1. Where do I put the
    : CSerialport port;
    : port.Open(bla bla bla)
    :
    : to ensure that the port is opened the instant the program is initiated, and only closes when the program exits? At the moment I'm stuck trying to figure out the scopes of each function. If I put the declaration in the message handler it works fine but i dont want the added time taken to open the port and close it again every time, plus I may have a different thread recieving at the same time or very shortly after. Where ever I put it it either throws compile-time errors about 'port' not existing or it closes it immediately after sending. Its simple in proceedural - you just lob the open in at the top and the close at the end, in a GUI i'm stuck :) I'd post the full code but I think people would get mad - its a long program.
    :
    : James
    :

  • coyoteboycoyoteboy Posts: 45Member
    : Where did you get this serialport.h file -- it is not a part of MFC.
    :
    : Check out this site; you might find your answer here.
    : http://www.codeguru.com/network/CSerialPort.html

    Thats where I got it from I think, but I have found a newer version that works as I expected it to - obviously some sort of a fix or the author has figured out how to cater for idiots like me :)

    Thanks
    James
Sign In or Register to comment.