reading serial port

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
MACKRACKIT
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Aug 03, 2005 7:12 pm

reading serial port

Post by MACKRACKIT » Mon Mar 20, 2006 1:55 am

Hi,
I have not been able to find an answer, but I am sure it is here some where. I have tried http://www.iftools.com/ctb.en.html and http://www.codeproject.com/system/serial.asp plus I have read every thing else that I could find.

I am running WIN98 using wx-devcpp. I can not even get the above code samples to compile. Found the above links at the wx-devcpp discussion board.

Problem: I have a pic chip sending data to the pc via serial port, this works as I can recieve with hyper-terminal. How do I set up a C++ program to recieve this data ?? I would like to have the data display into a text box so it can be saved to a database.

Thank you.

emarti
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:

Post by emarti » Mon Mar 20, 2006 2:34 am

According to me, you must use assembler language for in your compiler.
- T U R K E Y ?
- I love this country!

WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/

emarti
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:

Post by emarti » Mon Mar 20, 2006 2:49 am

If you wanna download this assembler projects. You may import dll at this project.

http://www.radasm.com/projects/ComTool050723.zip
- T U R K E Y ?
- I love this country!

WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/

MACKRACKIT
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Aug 03, 2005 7:12 pm

Post by MACKRACKIT » Mon Mar 20, 2006 11:09 pm

Thank you, I will give it a try.

__jerek__
In need of some credit
In need of some credit
Posts: 1
Joined: Mon Jul 03, 2006 4:13 pm

Post by __jerek__ » Wed Jul 05, 2006 8:36 pm

hello, MACKRACKIT

I'm too trying make the some thing of you.

I make this simulation in Proteus software
Image

the C code is:

Code: Select all

#include <16f628.H>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_A3, rcv=PIN_A2)

main() {

   printf("CONTROL LED WITH PIC\n\r");

   do {

      printf("\n\r");
      printf("Press any key to turn on led...\n\r");
      getch();
      output_high(pin_b0);

      printf("Press any key to turn off led...\n\r");
      getch();
      output_low(pin_b0);

   } while (TRUE);
}
but I don't know how to create the interfacing with the PC. Are you tryning yet?? pls contact me.

MACKRACKIT
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Aug 03, 2005 7:12 pm

Post by MACKRACKIT » Fri Jul 07, 2006 11:27 pm

Well mabey I should not say this here, but I did not have any luck with C. I know it can be done.

I have started using Liberty Basic for this kind of thing, for me it works, some may not like it.

To answer you question, do not try to access the pin on the micro chip directly. Send a string to the chip via serial and have the chip work with the string data.

PC sends 11
chip reads 11 and then moves this into a varible
if VAR=11 then SUB1
PC sends 22
chip reads 22 and then moves this into a varible
if VAR=22 then SUB2

You can then have the chip run with interupts or scan the pin that receives the serial data.

Hope this helps you out.

ra85665
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Aug 01, 2006 8:19 pm

Post by ra85665 » Tue Aug 01, 2006 8:27 pm

Hello everybody, I am new to wxWidgets and want to use serial port in both Windows and Linux. To be able to build Windows and Linux applications on my Fedora Core 4 box I installed 'native' RPMs with wxGTK-2.6.3 and also compiled the same version of wxWidgets for mingw32 target. The same things was done with wxCTB 0.8.
Now I am trying to write simple application to control modem. The Windows version seems to work as expected so far, but the Linux version drops segmentation fault on ReceiveUntilEOS call :-( Is there some other serial library for wxWidgets? Or should I rebuild wxGTK from sources as I did with wxMSW?

tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag » Wed Aug 02, 2006 1:34 pm

the wxCTB library works very well,

i use it for all my serial port communication programs.

despite the name, the wxCTB library itself does not need
wxWidgets to build and use, but it can of course be used
together with wxWidgets.

if you are interested, you can download a Code::Blocks
project file to build libwxctb-0.8.a from sources, which are
published by IF-Tools.

use this link for download
http://tiwag.cb.googlepages.com/home
-tiwag

ra85665
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Aug 01, 2006 8:19 pm

Post by ra85665 » Wed Aug 02, 2006 1:52 pm

Today I rebuild wxGTK as a static library, and also rebuild my application. Unfortunately it still did segfault on port read. Then I examine my executable with ldd and found that it was linked with wxCTB dynamically. I simply remove libwxctb-0.8.so from /usr/local/lib and rebuild my application again. Now libwxctb is statically linked and works as expected!

renaud.s
Knows some wx things
Knows some wx things
Posts: 43
Joined: Wed Feb 22, 2006 9:23 pm
Location: Belgium
Contact:

Post by renaud.s » Thu Aug 03, 2006 4:37 pm

I use wxCTB on win2k and winXP without problem. In my opinion it should works fine on win98 as wxCTB use standard win32 api.

What kind of compiling error do you get ?

ra85665
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Aug 01, 2006 8:19 pm

Post by ra85665 » Thu Aug 03, 2006 5:38 pm

What kind of compiling error do you get ?
As for me, I've no compile errors, I had some runtime errors until I force libwxCTB to link statically. Also, I haven't noted anybody reporting compile errors on this thread :-)

Post Reply