RE: RS-232C serial text strings

new topic     » topic index » view thread      » older message » newer message

David Oswald wrote:
> 
> Hello all you Euphers,
> I'm a newbe, and have much hope for using Euphoria in automation control 
> 
> and robotics applications.  I am writing my first Euphoria program to 
> create a GUI for controlling a machine micro-controller via the RS-232C 
> serial comm port.  This is pretty much the standard interface for just 
> about all micro-controllers.
> I am using Win32lib.e for the GUI to make its use by the machine's 
> humans friendly.  Everything works fine except the communication with 
> the controller.  I am trying to send and receive one string at a time 
> ending with a carriage return.  The open and puts statements seem to be 
> working, although I can't be sure.  But, when I use the "gets" command 
> my GUI locks with no err message displayed or written to err.txt
> I have done this before with Qbasic and have used that app to check the 
> hardware and cable connections, no problem there.  
> I have looked at the various .e files in the archive dealing with serial 
> 
> comm but they all seem to just handle single characters,  maybe I'm not 
> understanding there usage.
> 
> The Qbasic code sends and receives text one line at a time as follows:
> 
>     OPEN "COM2:9600,N,8,1,CS,DS" FOR RANDOM AS #1
>     PRINT #1, "PC" ' set protocol in CTC
>     LINE INPUT #1,  response$ ' response from CTC should be "PC0"
> 
> Any help would be greatly appreciated.
> Thanks,
> David Oswald
> 
hi david

i suspect the gets() is locking up because it's not finding the LF/CR or 
end of file. since the basic works, i suspect it's because the puts() is 
not in fact setting the protocol properly, so you're not getting a 
sensible response from the controller. and i suspect that's because 
there is a subtle difference between puts() in euphoria and PRINT in 
basic. in basic, PRINT automatically adds LF/CR to the end, unless it's 
followed by a comma (according to my book - i hardly ever use basic). 
puts() doesn't. you haven't sent us your euphoria code, but is the 
protocol line like this?
puts( 1, "PC\n" )

cheers
tacitus

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu