[Gambas-user] Re: Using serial component for plc comunications

Daniel daniel.campos at ...338...
Wed Jun 2 08:54:16 CEST 2004


El mié, 02-06-2004 a las 00:35, Marcelo Duschkin escribió:
> El Mar 01 Jun 2004 13:40, Daniel escribió:
> |> OK, there was an stupid bug in the SerialPort example I wrote:
> |> WRITE #Sport,TxtSend.Text & Chr(13) & Chr(10)
> |> Should be:
> |> WRITE #Sport,TxtSend.Text & Chr(13) & Chr(10),Len(TxtSend.Text)+2
> 
> I think I catched it :)
> Sport_Read react with the "CR" char, transferring all the chars in the input 
> buffer including it, BUT leaving the "LF".
> This is the annoying char in first place in the next read.
> Is that correct?


Well, the problem is that we were trying to send an array of bytes, but
using functions that were designed to work with UTF-8, in which, not
always 1 character = 1 byte, so, special characters like CR and LF can
cause these troubles, specially if two or more bytes does not make a
valid UTF-8 character.

Try, for example, writting any phrase with spanish characters like 'á'
or 'ñ' in the Udp example. I try to reverse the string just changing the
byte order, showing strange characters. (I've used a lot of times
StrReverse$ in VB even if Gambas does not support it:-) 

It is important to know the real lenght of a string to communicate, when
using UTF-8, and to make the appropiate codification changes if our
target device does not understand UTF-8!

Regards,

Daniel Campos

 

> 
> -- Para el cierre: ---
> El Pingüinoráculo solía citar:
> Los que crean en la telekinesis que levanten mi mano.
> - - -
> Marcelo Duschkin - Buenos Aires - Argentina
> mardus at ...298...
> www.websdelsur.com.ar
> www.lahueya.com.ar
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by the new InstallShield X.
> >From Windows to Linux, servers to mobile, InstallShield X is the one
> installation-authoring solution that does it all. Learn more and
> evaluate today! http://www.installshield.com/Dev2Dev/0504
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user





More information about the User mailing list