Real Software Forums
http://forums.realsoftware.com/

Sending binary Data with TCPSocket
http://forums.realsoftware.com/viewtopic.php?f=2&t=42611
Page 1 of 1

Author:  jcgarrido [ Thu Feb 09, 2012 3:55 am ]
Post subject:  Sending binary Data with TCPSocket

I'm implementing TCP Modbus protrocol with TCPSocket and I need to send a byte stream to a remote device. The only statement I know in order to do that is Write , that has an string argument.
I think that native string format is 16 bits per char, and I don't know what will hapen if I convert the byte stream to a string concatenating it (chr(byte(0))+chr(byte(1))+...) and sending with socket.write

In VB, SendData statement accept a byte array as argument.
Can I do that encoding with chrB and decoding with ascB and midB?

Thanks in advance.

Author:  timhare [ Thu Feb 09, 2012 3:12 pm ]
Post subject:  Re: Sending binary Data with TCPSocket

RB "native" strings are UTF-8 encoded, which means that characters can be 1-4 bytes wide. Values less than 127 are always single bytes. The "B" versions - chrb, ascb, midb - are all single byte operations, so you can use chrb(0) thru chrb(255) and be assured of a single byte. That will give you a string suitable for socket.write operations.

Author:  jcgarrido [ Fri Feb 10, 2012 2:27 am ]
Post subject:  Re: Sending binary Data with TCPSocket

I'm trying it. Thanks a lot.
Regards.

Author:  quicomm [ Fri Jan 04, 2013 8:55 pm ]
Post subject:  Re: Sending binary Data with TCPSocket

jcgarrido: did you ever get your Modbus TCP routines working (as a Master)? I have a RealBasic project where I need to use Modbus TCP to communicate with two sets of DIN rail mounted counters and digital outputs. I would be willing to purchase the code from you if available (hate reinventing the wheel).

thank you,
--- Brad Bennett

Author:  simulanics [ Sun Jan 06, 2013 2:26 pm ]
Post subject:  Re: Sending binary Data with TCPSocket

Im going to take a look on the net...believe I've come across an open source modbus implementation...

Author:  p0wn3d [ Sun Jan 06, 2013 3:20 pm ]
Post subject:  Re: Sending binary Data with TCPSocket

You could always call some python from within your RB apps

http://code.google.com/p/modbus-tk/

:wink:

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/