Solved

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

Posted on 2004-09-23
10
667 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Within a class, declare a function/method as static or not 16 132
why "." vs "->" 23 119
AVI wait icons for CAnimateCtrl in Visual Studio 2008 MFC 1 120
Header of docx file 17 98
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

896 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now