Solved

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

Posted on 2004-09-23
10
665 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

758 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

21 Experts available now in Live!

Get 1:1 Help Now