Solved

RS232 C++ Library that will work with Bloodshed C++

Posted on 2004-09-23
10
670 Views
Last Modified: 2008-01-09
I am writing a program on Bloodshed C++ (long story short, we were trying to make a cross-platform/platform independent interface and I wrote on this using wxWidgets as my library.  Now, we are adding Serial Port communications and I can't find a way to access the Serial Ports.  Does anyone know of a way to do this fairly simply?  I'm just going to be doing very basic communication on this port and don't need sophisticated calls.  Basic input/output in single streams.

Ideas, anyone?
0
Comment
Question by:vivekpara
  • 4
  • 3
  • 3
10 Comments
 
LVL 11

Expert Comment

by:griessh
ID: 12135145
Hi vivekpara,

Serial ports are always hardware on your system. In order to access them you always need some kind of driver for it or direct access or calls into your BIOS (depending on platform and OS). This makes the whole Serial Port issues very much depending on your system.

So the short answer would be: No, there is no simple library you can use across different platforms.

======
Werner
0
 
LVL 2

Author Comment

by:vivekpara
ID: 12135466
Well...if I just want to use this IDE for programming (as I've already invested to much to let it go), can wxWidgets make DDE calls to a service I create in MFC?  I will have the service do all the Serial Communication...just communicate its returns to my program.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 12135769
I have never heard about a portable serial library. It is extremely OS dependent (maybe not so much hardware dependent because OS does this task for you).
But you can find lots of system specific libraries. By example: for Windows you can find many at codeproject.com.

http://www.codeproject.com/system/chaiyasit_t.asp
http://www.codeproject.com/system/serial.asp
http://www.codeproject.com/system/cserialport.asp
http://www.codeproject.com/system/serial_com.asp
http://www.codeproject.com/system/simpleserialcomm.asp

Maybe you can use any of them as a foundation and add other OS support by using compiler directives (#ifdef LINUX.... etc)
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 11

Expert Comment

by:griessh
ID: 12135940
>> maybe not so much hardware dependent because OS does this task for you

Quite the opposite!
- "High level" OSs don't care about that at all, that's why you have to provide a driver to communicate with the hardware.
- "Low Level" OSs (like MSDOS) rely on BIOS functions.
- For Embedded OSs you will have to provide the access methods together with your hardware.

=====
Werner
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12136003
I will give you an example with Windows, the most OS I use:
If you wan't to access serial port use this:

Windows 95: CreateFile / ReadFile / WriteFile / BuildCommDCB
Windows 98: CreateFile / ReadFile / WriteFile / BuildCommDCB
Windows Me: CreateFile / ReadFile / WriteFile / BuildCommDCB
Windows NT: CreateFile / ReadFile / WriteFile / BuildCommDCB
Windows 2000: CreateFile / ReadFile / WriteFile / BuildCommDCB
Windows XP: CreateFile / ReadFile / WriteFile / BuildCommDCB
Windows CE: CreateFile / ReadFile / WriteFile / BuildCommDCB
Embedded Windows XP: CreateFile / ReadFile / WriteFile / BuildCommDCB

You dont have to worry about a DRIVER, all mayor OS comes with a serial driver.
0
 
LVL 2

Author Comment

by:vivekpara
ID: 12136109
I'm using all high level OS, but targetting for right now WinXP.  I am having some trouble compiling the PJ Naughter CSerial library.  I'm going to try a few others.  Any idea why it keeps saying that variables were created but not initiated?  I tried it with the test app that came with it and got these errors.  Very strange.

What I'm thinking now is that I will build an NT service to provide direct communication to my PIC chip.  I'm going to use DDE to communicate to my program.  If I need to ever move to Linux, I can change the service to a Daemon and use wxWidgets to make communication calls using TCP/IP.

0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12136183
DDE is extremely system dependent. Also not so used nowadays. Why your app don't talk directly to your PIC?, I don't think to make a service is a good idea if your app will be the unique to use it.
All you have to do is to design an object that access the serial port, for Linux design an identical object with the same functions, obviously with different implementation code.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12136215
About my previous comment, I forgot to mention that these serial function works identical in:
Intel 32 bits
Intel 64 bits
Intel StrongArm
Intel XScale
Hitachi SH3, SH4
PowerPC
MIPS
Arm
etc...
That's why I say there is little hardware dependency because always OS have a hardware abstraction layer.
The same will happen with Linux for:
Intel processors
Motorola processors
Sparc processors
MIPS processors
PowerPC
etc....
0
 
LVL 11

Expert Comment

by:griessh
ID: 12136260
I used MarshallSoft libraries a few years ago for different Windows and MSDOS projects. (You can get them at http://www.marshallsoft.com/products.htm ) They are easy to deal with, efficient and reliable, but only available for Windows ...

=====
Werner
0
 
LVL 2

Author Comment

by:vivekpara
ID: 12137658
I've gotten the basic executable working and am trying to turn it in to a service.  That CSerial file is pretty cool for simple communication invocation.  I can write and read just fine...which is all I'm trying to do...nothing complex.  I'll wait on the Linux stuff until it bites me on me AA**************!!!

Thanks, All!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question