reading data from serial port - 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.

reading data from serial port

MoncktonMonckton Posts: 6Member
I have a micro-controller which will output a number, i need to read this number using my c/c++ program from the com port.
Can anybody please tell me how! P.s i can receive the number using hyperterminal no problem so i know the processor is working. Thanks

Comments

  • LundinLundin Posts: 3,711Member
    : I have a micro-controller which will output a number, i need to read this number using my c/c++ program from the com port.
    : Can anybody please tell me how! P.s i can receive the number using hyperterminal no problem so i know the processor is working. Thanks
    :
    :

    This is a common question, so you can find plenty of code if you search these boards for "serial port" or "RS-232".
  • MoncktonMonckton Posts: 6Member
    : : I have a micro-controller which will output a number, i need to read this number using my c/c++ program from the com port.
    : : Can anybody please tell me how! P.s i can receive the number using hyperterminal no problem so i know the processor is working. Thanks
    : :
    : :
    :
    : This is a common question, so you can find plenty of code if you search these boards for "serial port" or "RS-232".
    :
    Thank You, I have downloaded lots of code but am having no luck compiling it. i have Borland command line compiler and dev-cpp. the problem is the executable that comes with the download will run ok but if i try to compile the program myself it will not. I have copied the relevant header files and lib files into the correct directories. Is the problem likely to be with the compiler? or am i missing something else...?
  • LundinLundin Posts: 3,711Member
    : : : I have a micro-controller which will output a number, i need to read this number using my c/c++ program from the com port.
    : : : Can anybody please tell me how! P.s i can receive the number using hyperterminal no problem so i know the processor is working. Thanks
    : : :
    : : :
    : :
    : : This is a common question, so you can find plenty of code if you search these boards for "serial port" or "RS-232".
    : :
    : Thank You, I have downloaded lots of code but am having no luck compiling it. i have Borland command line compiler and dev-cpp. the problem is the executable that comes with the download will run ok but if i try to compile the program myself it will not. I have copied the relevant header files and lib files into the correct directories. Is the problem likely to be with the compiler? or am i missing something else...?
    :

    What errors do you get?
    I don't know what those extra lib-files are, if you are going to use the Win API functions, then you will need no extra files besides the windows.h provided with the compiler.

  • MoncktonMonckton Posts: 6Member
    : : : : I have a micro-controller which will output a number, i need to read this number using my c/c++ program from the com port.
    : : : : Can anybody please tell me how! P.s i can receive the number using hyperterminal no problem so i know the processor is working. Thanks
    : : : :
    : : : :
    : : :
    : : : This is a common question, so you can find plenty of code if you search these boards for "serial port" or "RS-232".
    : : :
    : : Thank You, I have downloaded lots of code but am having no luck compiling it. i have Borland command line compiler and dev-cpp. the problem is the executable that comes with the download will run ok but if i try to compile the program myself it will not. I have copied the relevant header files and lib files into the correct directories. Is the problem likely to be with the compiler? or am i missing something else...?
    : :
    :
    : What errors do you get?
    : I don't know what those extra lib-files are, if you are going to use the Win API functions, then you will need no extra files besides the windows.h provided with the compiler.
    :
    : I was not using the Win API functions (I Dont know how)and it seems my problem is with the bios.h header file. Is it best for me to use the Win API functions and do you have any recomendations (books etc..on where i should start looking?

  • LundinLundin Posts: 3,711Member
    : : : : : I have a micro-controller which will output a number, i need to read this number using my c/c++ program from the com port.
    : : : : : Can anybody please tell me how! P.s i can receive the number using hyperterminal no problem so i know the processor is working. Thanks
    : : : : :
    : : : : :
    : : : :
    : : : : This is a common question, so you can find plenty of code if you search these boards for "serial port" or "RS-232".
    : : : :
    : : : Thank You, I have downloaded lots of code but am having no luck compiling it. i have Borland command line compiler and dev-cpp. the problem is the executable that comes with the download will run ok but if i try to compile the program myself it will not. I have copied the relevant header files and lib files into the correct directories. Is the problem likely to be with the compiler? or am i missing something else...?
    : : :
    : :
    : : What errors do you get?
    : : I don't know what those extra lib-files are, if you are going to use the Win API functions, then you will need no extra files besides the windows.h provided with the compiler.
    : :
    : : I was not using the Win API functions (I Dont know how)and it seems my problem is with the bios.h header file. Is it best for me to use the Win API functions and do you have any recomendations (books etc..on where i should start looking?
    :
    :

    bios.h is for DOS. If you see a future as DOS-programmer, then that is the right file :-)
    Seriously, sence you have modern compilers, I suggest that you use modern functions. You don't need to know much about Win API programming to use those functions. All the functions you need are ReadFile, WriteFile, CreateFile, GetCommState, SetCommState, GetCommTimeouts, SetCommTimeouts.

    Search these boards for examples and www.msdn.microsoft.com for documentation. MSDN also has examples:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/configuring_a_communications_resource.asp

    If you want to look into Win API programming, then you should get the book "Programming Windows" by Charles Petzold, ISBN 1-57231-995-X. It is a classic book (the "windows bible").
  • MoncktonMonckton Posts: 6Member
    : : : : : : I have a micro-controller which will output a number, i need to read this number using my c/c++ program from the com port.
    : : : : : : Can anybody please tell me how! P.s i can receive the number using hyperterminal no problem so i know the processor is working. Thanks
    : : : : : :
    : : : : : :
    : : : : :
    : : : : : This is a common question, so you can find plenty of code if you search these boards for "serial port" or "RS-232".
    : : : : :
    : : : : Thank You, I have downloaded lots of code but am having no luck compiling it. i have Borland command line compiler and dev-cpp. the problem is the executable that comes with the download will run ok but if i try to compile the program myself it will not. I have copied the relevant header files and lib files into the correct directories. Is the problem likely to be with the compiler? or am i missing something else...?
    : : : :
    : : :
    : : : What errors do you get?
    : : : I don't know what those extra lib-files are, if you are going to use the Win API functions, then you will need no extra files besides the windows.h provided with the compiler.
    : : :
    : : : I was not using the Win API functions (I Dont know how)and it seems my problem is with the bios.h header file. Is it best for me to use the Win API functions and do you have any recomendations (books etc..on where i should start looking?
    : :
    : :
    :
    : bios.h is for DOS. If you see a future as DOS-programmer, then that is the right file :-)
    : Seriously, sence you have modern compilers, I suggest that you use modern functions. You don't need to know much about Win API programming to use those functions. All the functions you need are ReadFile, WriteFile, CreateFile, GetCommState, SetCommState, GetCommTimeouts, SetCommTimeouts.
    :
    : Search these boards for examples and www.msdn.microsoft.com for documentation. MSDN also has examples:
    : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/configuring_a_communications_resource.asp
    :
    : If you want to look into Win API programming, then you should get the book "Programming Windows" by Charles Petzold, ISBN 1-57231-995-X. It is a classic book (the "windows bible").
    :
    Thank You
  • MoncktonMonckton Posts: 6Member
    : : : : : : : I have a micro-controller which will output a number, i need to read this number using my c/c++ program from the com port.
    : : : : : : : Can anybody please tell me how! P.s i can receive the number using hyperterminal no problem so i know the processor is working. Thanks
    : : : : : : :
    : : : : : : :
    : : : : : :
    : : : : : : This is a common question, so you can find plenty of code if you search these boards for "serial port" or "RS-232".
    : : : : : :
    : : : : : Thank You, I have downloaded lots of code but am having no luck compiling it. i have Borland command line compiler and dev-cpp. the problem is the executable that comes with the download will run ok but if i try to compile the program myself it will not. I have copied the relevant header files and lib files into the correct directories. Is the problem likely to be with the compiler? or am i missing something else...?
    : : : : :
    : : : :
    : : : : What errors do you get?
    : : : : I don't know what those extra lib-files are, if you are going to use the Win API functions, then you will need no extra files besides the windows.h provided with the compiler.
    : : : :
    : : : : I was not using the Win API functions (I Dont know how)and it seems my problem is with the bios.h header file. Is it best for me to use the Win API functions and do you have any recomendations (books etc..on where i should start looking?
    : : :
    : : :
    : :
    : : bios.h is for DOS. If you see a future as DOS-programmer, then that is the right file :-)
    : : Seriously, sence you have modern compilers, I suggest that you use modern functions. You don't need to know much about Win API programming to use those functions. All the functions you need are ReadFile, WriteFile, CreateFile, GetCommState, SetCommState, GetCommTimeouts, SetCommTimeouts.
    : :
    : : Search these boards for examples and www.msdn.microsoft.com for documentation. MSDN also has examples:
    : : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/configuring_a_communications_resource.asp
    : :
    : : If you want to look into Win API programming, then you should get the book "Programming Windows" by Charles Petzold, ISBN 1-57231-995-X. It is a classic book (the "windows bible").
    : :
    : Thank You
    :
    Well i have ordered the book and am looking forward to learning...
    I have searched the web for info and code using the API programming. It would appear that all of the available code is written in Visual C++ not C/C++. Should i be learning Visual C++ or is it possible to write in C/C++?
  • stoberstober Posts: 9,765Member ✭✭✭
    [b][red]This message was edited by stober at 2004-12-26 18:31:15[/red][/b][hr]
    : Well i have ordered the book and am looking forward to learning...
    : I have searched the web for info and code using the API programming. It would appear that all of the available code is written in Visual C++ not C/C++. Should i be learning Visual C++ or is it possible to write in C/C++?
    :

    Visual C++ is a compiler, not a language. It compiles both C and C++ code for the MS Windows operating system. you cannot compile 16-bit MS-DOS programs with it.


  • MoncktonMonckton Posts: 6Member
    : [b][red]This message was edited by stober at 2004-12-26 18:31:15[/red][/b][hr]
    : : Well i have ordered the book and am looking forward to learning...
    : : I have searched the web for info and code using the API programming. It would appear that all of the available code is written in Visual C++ not C/C++. Should i be learning Visual C++ or is it possible to write in C/C++?
    : :
    :
    : Visual C++ is a compiler, not a language. It compiles both C and C++ code for the MS Windows operating system. you cannot compile 16-bit MS-DOS programs with it.
    Thanks for your reply.
    All of the downloadable code and tutorials i have found so far will not compile using my Borland command line or Dev-Cpp compilers and the syntax for the programs appears different to that of c/c++.
    i.e Vc++ uses Cserial::Cserial() this is not included in my compilers...
    Am i missing something simple?
    :
    :
    :

  • stoberstober Posts: 9,765Member ✭✭✭
    : Thanks for your reply.
    : All of the downloadable code and tutorials i have found so far will not compile using my Borland command line or Dev-Cpp compilers and the syntax for the programs appears different to that of c/c++.
    : i.e Vc++ uses Cserial::Cserial() this is not included in my compilers...
    : Am i missing something simple?
    : :

    CSerial is NOT a class that is normally defined by VC++ 6.0 compiler. you are obviously missing the .h file that contains the class definition. check your download files to see if you have the .h file.
Sign In or Register to comment.