AOA AOA AOA Folding For Team 45 AOA Files Home Front Page Become an AOA Subscriber! UserCP Calendar Memberlist FAQ Search Forum Home


Go Back   AOA > Software > Programming and Assembly Language
Register FAQ Members List Calendar Arcade Search Today's Posts Mark Forums Read

Programming and Assembly Language Please read this Topic's rules!!


Reply
 
LinkBack Thread Tools Rate Thread
  #1 (permalink)  
Old 2nd April, 2004, 06:04 PM
SoddemFX's Avatar
Member
 
Join Date: November 2003
Location: Newcastle Under Lyme - Staffordshire - UK
Posts: 90

C++ programming with serial port

Hi, im writing my first GUI and have chose to use Borlands C++ Builder. The GUI requires information to be sent and recieved over a RS-232 serial port. My problem is that whilst im competent at using C to do this, im having a nightmare doing it in C++

If anyone here has done serial communication in C++ before, could you give me some info or URL's i might find of use (examples with code would be extremly helpfull).

Ive tried searching but havent found anything of use

My heartfelt thanks to anyone who can help out

Tom
__________________
Vapour Voltage Clock
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 2nd April, 2004, 06:17 PM
Gizmo's Avatar
Chief BBS Administrator
 
Join Date: May 2003
Location: Webb City, Mo
Posts: 13,949
Send a message via ICQ to Gizmo Send a message via AIM to Gizmo Send a message via MSN to Gizmo Send a message via Yahoo to Gizmo Send a message via Skype™ to Gizmo

What exactly is your problem? You should be able to do anything in C++ that you can do in C.
__________________
Avatar and sig graphic by Pitch. Subscribers!
Ask about a custom graphic or avatar today!
 
Later,
Gizmo
Thermal Diode Mod and Direct-Die Water Block
8-Cheetah 18GiB U-2 SCSI
MegaRAID Enterprise 1500/128MiB
Samsung SyncMaster 955DF
TTGI/Superflower TTS-520 PSU
 

 
AOA Team filesAOA Team wcgAOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 2nd April, 2004, 06:39 PM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,855

I've just recently written an UART driver in assembly, and have written something similar in C++. What seems to be your problem??
__________________
AOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 2nd April, 2004, 06:42 PM
SoddemFX's Avatar
Member
 
Join Date: November 2003
Location: Newcastle Under Lyme - Staffordshire - UK
Posts: 90

Thats not the problem - i know C++ can use the serial port, its just that i havent got a clue how to!

C++ is very new to me and i've no idea how to control the registers used in the UART using it, thats the problem...
__________________
Vapour Voltage Clock
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 2nd April, 2004, 06:43 PM
SoddemFX's Avatar
Member
 
Join Date: November 2003
Location: Newcastle Under Lyme - Staffordshire - UK
Posts: 90

Sorry Allan, was posting at same time
__________________
Vapour Voltage Clock
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 2nd April, 2004, 07:01 PM
Gizmo's Avatar
Chief BBS Administrator
 
Join Date: May 2003
Location: Webb City, Mo
Posts: 13,949
Send a message via ICQ to Gizmo Send a message via AIM to Gizmo Send a message via MSN to Gizmo Send a message via Yahoo to Gizmo Send a message via Skype™ to Gizmo

What OS? Any of the WinNT-derived OSen are not going to allow you to have direct access to the Serial port (or any other hardware for that matter) without some trickery.

It has been several years since I've written anything to bit-bang the 16450/16550 UART. Since Allan seems to be more current, I'll let him tackle this.

Allan, you're up.
__________________
Avatar and sig graphic by Pitch. Subscribers!
Ask about a custom graphic or avatar today!
 
Later,
Gizmo
Thermal Diode Mod and Direct-Die Water Block
8-Cheetah 18GiB U-2 SCSI
MegaRAID Enterprise 1500/128MiB
Samsung SyncMaster 955DF
TTGI/Superflower TTS-520 PSU
 

 
AOA Team filesAOA Team wcgAOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 2nd April, 2004, 07:16 PM
SoddemFX's Avatar
Member
 
Join Date: November 2003
Location: Newcastle Under Lyme - Staffordshire - UK
Posts: 90

The 'C' progs work fine on Win2000...

If its any help i need to know how to control RTS, and DTR in the MCR, also how to check the LSR and read/write the base address in C++

Tom
__________________
Vapour Voltage Clock
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 2nd April, 2004, 07:35 PM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,855

Quote:
Originally Posted by SoddemFX
The 'C' progs work fine on Win2000...

If its any help i need to know how to control RTS, and DTR in the MCR, also how to check the LSR and read/write the base address in C++

Tom
Thats kinda fun, actually. I wrote an assembly driver to handle that this very afternoon!

However, in C++ I've only written a program that used HDLC via the RS232, but I have the C++ driver files for the UART we used. I could email them to you if you want? PM me with your email addy if you are interested.

The comments are in Danish, but I can translate some of them if you want.

Man, you gotta love assembly for stuff like this! Bit manipulation is just so much easier, me thinks. With this example, the amount of code lines isn't THAT much bigger with asm than with C++..
__________________
AOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 2nd April, 2004, 07:38 PM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,855

It is 3.30 in the middle of the night, I'd better hit the sack. I'll get back to you tomorrow.
__________________
AOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 2nd April, 2004, 08:07 PM
Gizmo's Avatar
Chief BBS Administrator
 
Join Date: May 2003
Location: Webb City, Mo
Posts: 13,949
Send a message via ICQ to Gizmo Send a message via AIM to Gizmo Send a message via MSN to Gizmo Send a message via Yahoo to Gizmo Send a message via Skype™ to Gizmo

Assembly ROCKS! Even on the x86, which is about the most PITA assembly I know.
__________________
Avatar and sig graphic by Pitch. Subscribers!
Ask about a custom graphic or avatar today!
 
Later,
Gizmo
Thermal Diode Mod and Direct-Die Water Block
8-Cheetah 18GiB U-2 SCSI
MegaRAID Enterprise 1500/128MiB
Samsung SyncMaster 955DF
TTGI/Superflower TTS-520 PSU
 

 
AOA Team filesAOA Team wcgAOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 2nd April, 2004, 08:08 PM
SoddemFX's Avatar
Member
 
Join Date: November 2003
Location: Newcastle Under Lyme - Staffordshire - UK
Posts: 90

You have PM

No problem, me too...

I'd probably agree with you on the assembler thing, the only assembler ive done has been with PIC's, but for low level stuff like this i imagine it would be perfect! Unfortunately i have to use C++

Tom
__________________
Vapour Voltage Clock
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 3rd April, 2004, 04:49 AM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,855

Ahh, just got up.

Replied to your email, I'll get on with the translation of the files.

We do use x86 assembly at college, on Pentium-166 CPU's with lots of headroom for most tasks.
__________________
AOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 6th April, 2004, 06:18 AM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,855

So, does it work?
__________________
AOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 6th April, 2004, 07:24 AM
SoddemFX's Avatar
Member
 
Join Date: November 2003
Location: Newcastle Under Lyme - Staffordshire - UK
Posts: 90

Still working on it... The API's used in C++ for the serial communication are identical to those used in Visual Basic, so for now im just writing the GUI in VB (i need to get something working for Thursday, so i thought it would be better to concentrate on an *easier* method of VB ).

The C program for the slave PIC is complete, at the mo im making the interface board to connect it all together.

The way ive got it working at the mo is:

PC sends out request to slave PIC for either GPS, Compass or ADC - The slave PIC then relays the appropriate serial stream to the PC - The PC reads from serial buffer and displays it.

Had a few problems with intefacing the rs232 outputs from the devices to the slave PIC since they use different baud rates (i was originaly going to use a small multiplexor), have that sorted now

Its still going to be hectic tho...

Thanks for the help
__________________
Vapour Voltage Clock
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 6th April, 2004, 08:55 AM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,855

Sounds good, be sure to tell us about the final result. I hope the files that I sent helped you a bit in the project.

Good luck finishing it in time!
__________________
AOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 6th April, 2004, 04:08 PM
SoddemFX's Avatar
Member
 
Join Date: November 2003
Location: Newcastle Under Lyme - Staffordshire - UK
Posts: 90

Thanks - The final application will have to be written in C++ still (unless my project leader can be convinced otherwise!).

The files you sent were very helpfull

Will post a picture of the finished system when its done too....

Tom
__________________
Vapour Voltage Clock
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 7th April, 2004, 09:16 PM
SoddemFX's Avatar
Member
 
Join Date: November 2003
Location: Newcastle Under Lyme - Staffordshire - UK
Posts: 90

Hi, the attached shows the slave PIC board and the current (testing) GUI... its going to be "vero-boarded" and interfaced with the main board over the next few days...

Have attached it as a .zip so as not to annoy anyone with slower connections and save your bandwidth...

The picture of the board is low quality, i appologise in advance

Tom
Attached Files
File Type: zip pic_stuff.zip (314.5 KB, 71 views)
__________________
Vapour Voltage Clock
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 8th April, 2004, 03:34 AM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,855

Good luck vero-boarding it! Should make for a more permanent solution over the breadboard, eh? For some things I would prefer wire wrapping over soldering, mainly because my soldering skills aren't really up there.

Thanks for the pictures!!
__________________
AOA Team fah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 13th April, 2004, 09:54 PM
SoddemFX's Avatar
Member
 
Join Date: November 2003
Location: Newcastle Under Lyme - Staffordshire - UK
Posts: 90

Hi, got the whole system vero-boarded and running. Its got quite a few bugs still -but i'll get them sorted!

The systems comprises of 2 x PIC18F452's and 2 x PIC16C84's - its becoming quite a monster!

Got the GUI very nice now! Will post some pictures of the whole she-bang in the next few days when i can borrow a digital camera...

Tom
__________________
Vapour Voltage Clock
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 14th April, 2004, 10:54 AM
Allan's Avatar
Member/Contributer
 
Join Date: September 2001
Location: Denmark
Posts: 7,855

Thats great Tom, thanks for keeping me updated! I'll look forward to the pictures. Remember to take a snapshot of the GUI too...
__________________
AOA Team fah
Digg this Post!Add Post to del.icio.us