• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 692
  • Last Modified:

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

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
vivekpara
Asked:
vivekpara
  • 4
  • 3
  • 3
1 Solution
 
griesshCommented:
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
 
vivekparaAuthor Commented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
griesshCommented:
>> 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
 
Jaime OlivaresSoftware ArchitectCommented:
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
 
vivekparaAuthor Commented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
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
 
griesshCommented:
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
 
vivekparaAuthor Commented:
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 4
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now