[Gambas-user] Modbus on serial port
Benoit Minisini
gambas at ...1...
Sat Sep 17 19:42:36 CEST 2005
On Wednesday 14 September 2005 08:57, ariafrancesco at ...86... wrote:
> I am trying to implement the serial modbus protocol on gambas.
> Bookcase was my intention to create a class that all could use but I have a
> problem that I do not succeed to resolve. The instrument with which I try
> to communicate seems that it understands what I send but does not answer to
> me . What you know version 1,0,3 of gambas has of the problems with the
> object of the serial port?
>
> In order to create the string to send to the instrument I use:
>
> strOutput = Chr$(CByte(Val ("&H "& strNode))) & Chr$(3) & Chr$(CByte(Val
> ("&H" & Left$(varTemp, 2)))) & Chr$(CByte(Val ("&H "& Right$(varTemp, 2))))
> & Chr$(0) & Chr$(1)
>
> in order then to send it with:
>
> PRINT # Sport, (strOutput & Chr$(CByte(Val("&H "& Right$(strCRC, 2)))) &
> Chr$(CByte(Val("&H" & Left$(strCRC, 2)))))
If you don't end the PRINT with a semicolon, then a Chr$(10) is sent as end of
line. Is it what you want?
>
> Is possible that problem is the character set ?
> Gambas use UTF8 character set so is possible that using the Chr$ function
> the instrument does not understand?
You don't send strings on a serial port, you send bytes. Character set is only
used when displaying a byte sequence. And UTF-8 == ASCII when the byte is
between 0 and 127.
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list