Home » U++ Library support » U++ Library : Other (not classified elsewhere) » About RS232
Re: About RS232 [message #29855 is a reply to message #3788] |
Tue, 23 November 2010 03:50 |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
Looking at Serial.h and Serial.cpp they were not familiar to what I have previously used.
To help someone else this is what was done.
In my Python and Java code and the reason for doing it this way.
1. Loop through the ports from COM4 to COM20 (COM3 is the default for Win printer).
2. Loop through the ports to check the baud rate.
3. Open each port that returns the NMEA GPS GGA sentence that run concurrently, three is the most tried so far without threads, no problems.
Here is a snip of code to work with the Serial.h and Serial.cpp
Thread work;
void OpenAction() {
if (!CommPort.Open(6,57600)) Exclamation("Cannot open COM6");
Sleep(1000);
work.Run(THISBACK(Work));
}
void Work(){
char ch;
char buf1[1];
String St1;
while (CommPort.ReadDataWaiting() ) {
CommPort.ReadData(buf1, 1);
ch = buf1[0];
if(ch!='\n' || ch!='\r')St1 << ch;
if(ch=='\n'){
Data<<=St1;
...
Sleep(980);
The COM port and baud is hard coded here, the app will find and insert these parameters.
Note the Sleep(1000); before the work thread is run and Sleep(980);, otherwise the ReadDataWaiting() is empty.
This reads a char at a time but the parameter has to be a char buf, hence the necessity for char buf1[1];
This is very basic but shows how you can get data from a serial port you can work with. There is also a lot of try/catch, if(...), continue, break, parse(...), send(...), swear(), etc..
[Updated on: Tue, 23 November 2010 05:06] Report message to a moderator
|
|
|
|
|
About RS232
|
|
|
Re: About RS232
By: mirek on Mon, 26 June 2006 20:05
|
|
|
Re: About RS232
By: qwerty on Tue, 11 July 2006 19:44
|
|
|
Re: About RS232
By: qwerty on Mon, 11 September 2006 01:25
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: ebojd on Wed, 25 April 2007 20:39
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: forlano on Fri, 10 October 2008 21:33
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: forlano on Sat, 11 October 2008 11:17
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: forlano on Sat, 11 October 2008 23:07
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: forlano on Sun, 12 October 2008 23:03
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: forlano on Mon, 13 October 2008 23:00
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: forlano on Mon, 20 October 2008 19:27
|
|
|
Re: About RS232
By: gxl117 on Wed, 11 November 2009 08:44
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: gxl117 on Fri, 13 November 2009 04:40
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: Didier on Tue, 26 January 2010 22:54
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: Didier on Fri, 05 February 2010 00:19
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: Reini on Sat, 06 March 2010 18:42
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: Didier on Sun, 07 March 2010 13:38
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: Didier on Sun, 07 March 2010 19:50
|
|
|
Re: About RS232
By: Didier on Sun, 07 March 2010 20:56
|
|
|
Re: About RS232
By: mr_ped on Wed, 16 June 2010 16:55
|
|
|
Re: About RS232
By: Didier on Wed, 16 June 2010 22:08
|
|
|
Re: About RS232
By: mr_ped on Wed, 16 June 2010 16:57
|
|
|
Re: About RS232
By: jeremy_c on Fri, 20 August 2010 01:30
|
|
|
Re: About RS232
By: koldo on Fri, 20 August 2010 08:23
|
|
|
Re: About RS232
By: jerson on Fri, 20 August 2010 10:00
|
|
|
Re: About RS232
By: jeremy_c on Fri, 20 August 2010 13:58
|
|
|
Re: About RS232
By: koldo on Fri, 20 August 2010 14:30
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: jerson on Sun, 21 November 2010 16:21
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: jibe on Fri, 15 March 2013 14:40
|
|
|
Re: About RS232
By: Zbych on Fri, 15 March 2013 16:04
|
|
|
Re: About RS232
By: jibe on Fri, 15 March 2013 15:55
|
|
|
Re: About RS232
By: jerson on Fri, 15 March 2013 16:00
|
|
|
Re: About RS232
By: jibe on Fri, 15 March 2013 22:45
|
|
|
Re: About RS232
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: deep on Thu, 09 May 2013 08:58
|
|
|
Re: About RS232
|
|
|
Re: About RS232
By: jibe on Wed, 20 March 2013 15:22
|
Goto Forum:
Current Time: Fri Apr 26 12:57:21 CEST 2024
Total time taken to generate the page: 0.03844 seconds
|