Hi, as I said before most likely Modbus RTU or similar protocol. If so you will
need to do some BIT bashing and probably
some CRC conversion. You will need to know the frame size among other things.
Public Sub HbLb()
Dim Xz2 As Long
Hb = Fix(DataS / 256)
Xz2 = Fix(256 * Hb)
Lb = DataS -
it works fine - it was a strange serial port hardware issue. All the "Read"
methods suggested above work, Thanks to all!
--
View this message in context:
http://gambas.8142.n7.nabble.com/Serial-I-O-with-byte-data-tp58933p58995.html
Sent from the gambas-user mailing list archive at Nabble.com.
Alex,
Without knowing the protocol/device you're communicating with, I don't
think anyone will be able to give substantial help.
But, after years of interfacing very diverse hardware via RS-232 (fiscal
printers, cash-hanlding hardware, GPS, you name it!), I can tell you
that it's not always easy,
&H02 is ASCII for STX, a special char that for some protocols mean "start
transmission".
Some protocols frame their data payload between chars STX (&H02) and ETX(&H03).
These also normally use some checksum mechanism either before or right after
ETX.
Of course it could also be a misleading UTF8
Hmm eureka, it's 02 53 = 0x53
Or 02 25 = 0x25...
Where could that 02 be from?
Cheers!
--
View this message in context:
http://gambas.8142.n7.nabble.com/Serial-I-O-with-byte-data-tp58933p58986.html
Sent from the gambas-user mailing list archive at Nabble.com.
-
Thanks, it works (both with .tostring and reading one by one...
But I get values I don't know how to convert, e.g. where I expect a decimal
83 or hex 53 I get byte value of 253 ... Or instead of Decimal 15 I get 225
:(
cheers!
--
View this message in context:
http://gambas.8142.n7.nabble.com
To: mailing list for gambas users
Sent: Mon, 15 May 2017 10:46:01 +0000 (UTC)
Subject: Re: [Gambas-user] Serial I/O with byte data
> If you are talking about a byte the likes of that used in modbusrtu you will
> need to do some high low bit manipulation on it. RegardsMike
>
>
If you are talking about a byte the likes of that used in modbusrtu you will
need to do some high low bit manipulation on it.
RegardsMike
On Monday, 15 May 2017, 13:19, Alexie wrote:
Following should work for you:
Public Sub XXX_Read()
Dim iLen As Integer
Dim aData As Byte[]
i
Following should work for you:
Public Sub XXX_Read()
Dim iLen As Integer
Dim aData As Byte[]
iLen = Lof(Last)
aData = New Byte[]
aData.Resize(iLen)
Try aData.Read(Last, 0, iLen)
End
You need to get the length (lof) first, then resize array ... only then you
can read it.
2017-05-14
On Sun, 14 May 2017, alexchernoff wrote:
> Good day all,
>
> Anyone know how to read data received on serial port into an array of bytes
> instead of string?
>
I think that's not possible.
> String gets unreadable binary characters, so how can I
> put them into byte[] or so?
>
This shouldn'
Good day all,
Anyone know how to read data received on serial port into an array of bytes
instead of string? String gets unreadable binary characters, so how can I
put them into byte[] or so?
Thanks!
--
View this message in context:
http://gambas.8142.n7.nabble.com/Serial-I-O-with-byte-d
On 05/08/2017 12:13 PM, alexchernoff wrote:
> Dear all,
>
> I am receiving data over a serial port which is sent by a byte[].write
> function (an array of bytes)
>
> I get the SerialPort1_read() event raised where I try to read data, RxBuffer
> is a string var
>
> *Try Read #SerialPort1, RxBuffe
openwebmail.org)
-- Original Message ---
From: alexchernoff
To: gambas-user@lists.sourceforge.net
Sent: Mon, 8 May 2017 22:45:11 -0700 (MST)
Subject: Re: [Gambas-user] Serial I/O with byte data
> Thanks Mike,
>
> what I have is pretty much the same, it's this line that c
Thanks Mike,
what I have is pretty much the same, it's this line that causes everything
to stop.
*Read #Sport, Rx, Lof(Sport) *
A very similar program written in Xojo on the same system using same serial
port works just fine. In Gambas, things just stop executing as soon as I do
a Read on that
Hi Alex, have a look at this code for some ideas how I have serial comms
working.
' Gambas class file
Private Sport As SerialPort
Public Pp As Byte
Public Po As Byte
Public Rxs As String
Public Sub Form_Open()
Me.Load
Me.Center
End
Public Sub Button2_Click()
Sport = New SerialPort As "Spo
Dear all,
I am receiving data over a serial port which is sent by a byte[].write
function (an array of bytes)
I get the SerialPort1_read() event raised where I try to read data, RxBuffer
is a string var
*Try Read #SerialPort1, RxBuffer, Lof(SerialPort1)*
as soon as I do, the whole program stops
16 matches
Mail list logo