Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Serial and USB port interface with C++

Status
Not open for further replies.

haglis

Newbie level 2
Joined
Jan 20, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Aberdeen, Scotland
Activity points
1,309
c++ usb

Hi,

I am returning to programming after a few years networking. I was previously well versed in COBOL, CICs, Easytrieve, REXX, Clist etc all on mainframes.

So I am quite good with most concepts, analysis and design etc and more or less, I hope, have just to get to grips with the syntax of the new technologies like C++. An over simplification I know, but I am optomistic.

Anyway, I have already found a small project at a local engineering company where I need to access 3 devices via serial (9-pin) ports and via USB from a pc running windows XP.

So I want to know if C++ can actually interface with USB and serial ports thru windows/dos ?

I am planning to learn several new languages, VB, VC++, .Net etc etc , but I need the first one that I learn to be capable of this interface with the hardware.

I havent actually begun learning much yet, so am looking for direction on where to start and perhaps where from there on, from people who are already well aware of the latest technologies.

I thought C++ might be a good place to start as its a popular technology and well used.

So, if C++ can do it, can you point me in the direct of how I can find out how I can do this, or tell me which language I should be looking at first.

I have been told the Dietel and Dietel C++ How to Program is a good book to learn from and use as a reference. but I dont want to spend money on that right now if C++ is not going to do the job I need it too.

Any help or advice would be greatly appreciated.

Regards, George
 

daviddlc

Full Member level 5
Joined
Feb 11, 2007
Messages
260
Helped
35
Reputation
70
Reaction score
9
Trophy points
1,298
Location
USA
Activity points
2,709
usb c++

You will have plenty of information about Serial Communication since nowadays is almost obsolete.

USB is a way different thing, "USB Complete" from Jan Axelson is a good guide but you still will need for information on the web.

To interface devices in Windows you will need the SDK or DDK.
 

btbass

Advanced Member level 5
Joined
Jul 20, 2001
Messages
1,897
Helped
438
Reputation
880
Reaction score
287
Trophy points
1,363
Location
Oberon
Activity points
12,861
c++ usb interface code

A good place to visit is: http://www.beyondlogic.org/
Plenty of information on Serial and USB interfacing.

You can download Borland C++ free from Code Central. This is a RAD IDE which makes it easy to program in Windows.
You interface to serial and usb through windows drivers. There are plenty of free serial and usb components on the net that work with Turbo C++. Delphi components will also work.
 

haglis

Newbie level 2
Joined
Jan 20, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Aberdeen, Scotland
Activity points
1,309
c++ usb port

Hi,

Thanks for the replies.

I have found a source for Jan Axelsons books, I will check them out.

btbass, if I understand you correctly you are saying I can use Borland C++ interfacing thru windows (XP) drivers or I can use Turbo C++ with some other components, including Delphi ?

Whats the difference between C++ (Borland or otherwise) and Turbo C++ ? Is one more commercially sought after by employers than the other ? As I will be looking for a permanent job at the end of this too.

I think the Deitel book also come with a version of a C++ compiler too. Is there much difference between the various compilers, and which would you recommended as most stable and popular ?

Thanks, George.
 

btbass

Advanced Member level 5
Joined
Jul 20, 2001
Messages
1,897
Helped
438
Reputation
880
Reaction score
287
Trophy points
1,363
Location
Oberon
Activity points
12,861
usb serial c

The full comercial version is CodeGear RAD studio, which came out of Borland Builder. Turbo C++ 2006, a free download, is an express version.

They are all essentially the same with differing features. They make it very easy to write proffesional looking windows applications. The Borland VCL (Visual component library) is a wrapper around the windows api. VCL components can be downloaded from the internet.
Delphi uses the same IDE as C++, the vcl is mostley written in object pascal (Delphi). The IDE can compile Delphi code so Delphi components can be used from Borland Builder C++.

More sought after by industry is Microsoft Visual Studio. I think this is driven more by management than coders, I personally find VC++ bloated and over complex.

With Visual studio, you could try C#. This is a modern typesafe language with elements of C++, Java, Delphi and others.
 

pkuhar

Newbie level 5
Joined
May 19, 2008
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,324
usb port interfacing

1.) New languages like Python,C#,Java ( in that order ) are easier to learn than C/C++. They all can access Serial Ports
Python - pyserial
Java - rxtx http://users.frii.com/jarvi/rxtx/
C# - build in

2.) Direct access to USB from user-space(not driver) program is possible via libusb or some propriatery API( several available). But I DON't recommend it if not absolutely necessary.
If you need USB support, better use some USB-Serial chip like FT232. This chip allready has drivers for most OS-es and can be accessed like a serial port.

In short use python and ft232. That way you can focus on the application.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top