Solved

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

Posted on 2004-09-23
10
673 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

730 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