Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » About RS232
About RS232 [message #3788] Mon, 26 June 2006 18:21 Go to next message
alvintseng is currently offline  alvintseng
Messages: 1
Registered: June 2006
Junior Member
May I use U++ to write the rs232 client program?
Re: About RS232 [message #3789 is a reply to message #3788] Mon, 26 June 2006 20:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
alvintseng wrote on Mon, 26 June 2006 12:21

May I use U++ to write the rs232 client program?


While there is no specific support, it is still regular C++, so everything you can do in C/Win32 API (or C/Posix/Linux API), you can do in U++ too...

Mirek
Re: About RS232 [message #3966 is a reply to message #3788] Tue, 11 July 2006 19:44 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
try libwxctb v0.8. it's great. I am using it in upp extensively.
here: http://www.iftools.com/ctb.en.html
I can send you a package, but it's really simple.

[Updated on: Tue, 11 July 2006 19:45]

Report message to a moderator

Re: About RS232 [message #5228 is a reply to message #3966] Mon, 11 September 2006 01:25 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
I've glued up together a working version(linux, win32) of 'plugin' of wxctb. if anyone interesed...
icon9.gif  Re: About RS232 [message #9267 is a reply to message #3788] Tue, 24 April 2007 19:34 Go to previous messageGo to next message
supertorresmo is currently offline  supertorresmo
Messages: 4
Registered: April 2007
Location: Brazil
Junior Member
I'm trying to implement an RS232 GUI program, but I had no success yet.

Does anyone have an working example?
Re: About RS232 [message #9287 is a reply to message #9267] Wed, 25 April 2007 20:39 Go to previous messageGo to next message
ebojd is currently offline  ebojd
Messages: 225
Registered: January 2007
Location: USA
Experienced Member
A cople of projects you might look at are Minicom <http://alioth.debian.org/projects/minicom> and Kermit <http://www.columbia.edu/kermit/>. You might run into licensing issues if you use their code, but it will give you something to compare against...

EBo --
Re: About RS232 [message #9309 is a reply to message #3788] Thu, 26 April 2007 13:40 Go to previous messageGo to next message
supertorresmo is currently offline  supertorresmo
Messages: 4
Registered: April 2007
Location: Brazil
Junior Member
I've finally got it working.

Here is what I did for anyone who might be interested:


MyClass::MyClass()
{
	CtrlLayout(*this, "Window title");
	Zoomable().Sizeable();
	connect <<= THISBACK(OnConnect);
	disconnect <<= THISBACK(OnDisconnect);
	send <<= THISBACK(OnSend);
	conectado = 0;
	SetTimeCallback(-1, callback(this, &MyClass::Timer));
}


GUI_APP_MAIN
{
	MyClass().Run();
}


void MyClass::OnConnect(){
	
	dev = new wxSerialPort();

	if(dev->Open(wxCOM1) < 0) {
		  PromptOK("Cannot open COM Port");
		  delete dev;
		  return;
	   }
	   // set the baudrate
	   conectado = 1;
	   ((wxSerialPort*)dev)->SetBaudRate(wxBAUD_57600);	
}

void MyClass::OnDisconnect(){
	
	conectado = 0;
	dev->Close();
        delete dev;
}

void MyClass::OnSend(){

	dev->Writev("Hellow",6,0);
}

void MyClass::Timer() {
	char ch;    
        int n = 0;
	
	if (conectado) {
    	n = dev->Read(&ch,1);
    	if (n>0)
    	editbox1.Insert(ch);
	}
	
}



This is a simple program that puts any incoming characters in a edit box and sens a "Hellow" string when the send button is pressed...
Re: About RS232 [message #13411 is a reply to message #9309] Fri, 04 January 2008 17:37 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Is this still the present state of serial port communication under UPP?

Are there any examples?

I have to say that I would rather do imperfect serial port programming and stay within the confines of UPP than start incorporating 3rd party code.

I am trying to read NMEA sentences from a (bluetooth)GPS connected to (virtual) serial port (3). I don't care about data loss as the GPS streams sentences continually. So long as I catch at least one whole sentence each time I look at the GPS port, I'm good. With this in mind, can anyone tell me why the following does not work?

MyClass::MyClass()
{
	CtrlLayout(*this, "Window title");
	Zoomable().Sizeable();

	SetTimeCallback(1000, callback(this, &MyClass::Timer));
	
}

void MyClass::Timer() 
{
	char cBuf[300];
	
	void* ptr = (void*)0x2f8;
	
	memcpy(cBuf,ptr,200);

	m_s.SetText(cBuf);
}

GUI_APP_MAIN
{
	MyClass().Run();
}


It throws an exception whenever I try to directly access the address 0x2f8

Any ideas or insults welcome Smile

EDIT: ah ok so I've found that direct access of these addresses is outlawed under newer versions of windows - great!

I am finding freely available serial port classes but they are either pre 1995 or written to run under MSVC and use handles etc. If I find one that can be converted I will post it here.

If anyone knows how to get around the windows access exception, I would be very happy to hear it.



Nick

[Updated on: Fri, 04 January 2008 18:24]

Report message to a moderator

Re: About RS232 [message #13414 is a reply to message #13411] Fri, 04 January 2008 23:48 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Nick, your code will of course throw an exception.
Mistakes you`ve made:
1) You try to read 0x2f8 address instead of port 2f8, which is usually connected with one of RS232 ports.
2) You try to read from port in Windows, where direct working with hardware ports is prohibited (if you`re not kernel-mode device driver).
3) Virtual COM-ports like bluetooth ones are not physical RS-232 ports. So there is no way to read them with any physical port, like 2f8.

Instead, you should do following:
1) Open port with CreateFile
2) Do reading/writing with ReadFile/WriteFile
3) Close the port with CloseHandle.

Things you must consider:
1) Your application must be multithreaded. One thread works with COM-port, while other thread respond to users`s GUI input.
2) You should make some kind of options or config, where to change COM-port number and it`s settings (speed, timeouts, etc) without recompiling the program

I strongly recommend you reading these topics:
(basic)
MSDN: CreateFile, ReadFile, WriteFile (COM-ports)
MSDN: Threads
U++: Config
(intermediate)
MSDN: Threads synchronization
(advanced)
MSDN: Overlapped i/o

Recently I`ve written U++ class, which makes all the hard work with COM-port. You should only write appropriate callbacks. For now, it works only for Windows, since I`m just starting learning Linux. If it`s needed in current state of development - I`ll upload it here.
Re: About RS232 [message #13434 is a reply to message #13414] Sun, 06 January 2008 03:26 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Thanks! I'll checkout your suggestions.

I actually managed to find a freely available serial port class that works under windows but I suspect it wont work under linux.

I would be very interested in a U++ class that works under both linux and windows but I am happy to wait until you have it finished - that would be fantastic.

I managed to write a small app that reads location from a bluetooth GPS and if anyone wants it I'll happily post it here. However, I think what you propose sounds way better. I hope that it gets incorporated into the next release of U++.

Thanks for replying,

Nick
Re: About RS232 [message #18595 is a reply to message #13414] Fri, 10 October 2008 21:33 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Mindtraveller wrote on Fri, 04 January 2008 23:48


Recently I`ve written U++ class, which makes all the hard work with COM-port. You should only write appropriate callbacks. For now, it works only for Windows, since I`m just starting learning Linux. If it`s needed in current state of development - I`ll upload it here.


Hello,

please let me ask you if your class is already included in the current 2008.1 or it is still under development.
Even in this state, if available, it could be very useful. I have got a temperature sensor connected to COM 1 and I would like to read it within U++.

Bolshoie spasiba!
Luigi
Re: About RS232 [message #18597 is a reply to message #18595] Fri, 10 October 2008 22:49 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

For now class is working good and only for Windows. It already was refactoried and tested in released application. The main drawback is lack of *nix support - this was the cause of not-publishing it into U++ (also I didn`t discuss it`s adding at all). If you need Windows-only version I`ll prepare it and post in this thread tomorrow.

[Updated on: Fri, 10 October 2008 22:51]

Report message to a moderator

Re: About RS232 [message #18605 is a reply to message #18597] Sat, 11 October 2008 11:17 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Mindtraveller wrote on Fri, 10 October 2008 22:49

If you need Windows-only version I`ll prepare it and post in this thread tomorrow.


Windows is quite enough at the moment.
Thanks,
Luigi
Re: About RS232 [message #18610 is a reply to message #18605] Sat, 11 October 2008 22:36 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Here are these files: ConveyorThread.h & RS232Thread.h
You should use RS232Thread class.

Kran.h & main.cpp are files from sample project which uses RS232Thread class.

Currently I`m writing manual for RS232Thread. It will be ready within some days. Hope it will answer your questions.
  • Attachment: ConveyorThread.h
    (Size: 3.10KB, Downloaded 792 times)
  • Attachment: RS232Thread.h
    (Size: 6.72KB, Downloaded 1249 times)
  • Attachment: main.cpp
    (Size: 7.87KB, Downloaded 917 times)
  • Attachment: Kran.h
    (Size: 1.16KB, Downloaded 826 times)
Re: About RS232 [message #18611 is a reply to message #18610] Sat, 11 October 2008 23:07 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Mindtraveller wrote on Sat, 11 October 2008 22:36

Here are these files: ConveyorThread.h & RS232Thread.h
You should use RS232Thread class.

Kran.h & main.cpp are files from sample project which uses RS232Thread class.

Currently I`m writing manual for RS232Thread. It will be ready within some days. Hope it will answer your questions.


Hi Pavel,

Is it possible to have even the Kran.lay file in order to have a working example? The file with extension .iml I suppose is not important.

Thanks a lot,
Luigi
Re: About RS232 [message #18616 is a reply to message #18611] Sun, 12 October 2008 09:40 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Here is an archive with my project. Hope this helps.
  • Attachment: 4.ZIP
    (Size: 34.43KB, Downloaded 926 times)
Re: About RS232 [message #18628 is a reply to message #18616] Sun, 12 October 2008 22:35 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Half of manual is written. If you wait for a couple of days, you won`t have to dig into my code with comments in Russian. Smile
Re: About RS232 [message #18630 is a reply to message #18628] Sun, 12 October 2008 23:03 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Mindtraveller wrote on Sun, 12 October 2008 22:35

Half of manual is written. If you wait for a couple of days, you won`t have to dig into my code with comments in Russian. Smile


Soglassian!

I'll wait as many days you need Smile
Your package compiles and run, but I have not understood how to get the data from the device connected to the serial port.
At the moment I've a working console example for linux and it uses the class "termios". It seems that the most important part is done by the line

/* get a line of data from the sensor */
p = serial_read(buffer, 128);

and then performs some parsing of the string buffer. So I need to know how to open the connection, retrieve the string, close the connection.

Luigi

[Updated on: Sun, 12 October 2008 23:05]

Report message to a moderator

icon3.gif  Re: About RS232 [message #18637 is a reply to message #18630] Mon, 13 October 2008 20:08 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Here is an archive with my manual. It is almost finished - last advanced topic is to be written. In it`s current condition Manual will likely answer the most of your questions.
I`d apreciate any comments and suggestions.

Extract this archive into your package (project) directory and you will find documentation in TheIDE help within your package node.

[Updated on: Mon, 13 October 2008 20:09]

Report message to a moderator

Re: About RS232 [message #18639 is a reply to message #18637] Mon, 13 October 2008 23:00 Go to previous messageGo to previous message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Mindtraveller wrote on Mon, 13 October 2008 20:08

Here is an archive with my manual. It is almost finished - last advanced topic is to be written. In it`s current condition Manual will likely answer the most of your questions.
I`d apreciate any comments and suggestions.

Extract this archive into your package (project) directory and you will find documentation in TheIDE help within your package node.


Hi,

thanks for the doc. Unfortunately the very important tutorial3 seems damaged. I can't read it after the phrase:

1. I just want to send some bytes to remote device.
ERROR: Invalid face number: ) void main()]&][s

Perhaps some character is not well parsed by my theide 2008.1 (perhaps have you used another version to prepare the docs?)

Luigi
Previous Topic: templated callback
Next Topic: Memory Mapped Files
Goto Forum:
  


Current Time: Thu Mar 28 11:11:56 CET 2024

Total time taken to generate the page: 0.02408 seconds