Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Jun 29, 2017 11:07 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Sending binary Data with TCPSocket
PostPosted: Thu Feb 09, 2012 3:55 am 
Offline

Joined: Wed Feb 08, 2012 9:33 am
Posts: 9
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Sending binary Data with TCPSocket
PostPosted: Thu Feb 09, 2012 3:12 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Sending binary Data with TCPSocket
PostPosted: Fri Feb 10, 2012 2:27 am 
Offline

Joined: Wed Feb 08, 2012 9:33 am
Posts: 9
I'm trying it. Thanks a lot.
Regards.


Top
 Profile  
Reply with quote  
 Post subject: Re: Sending binary Data with TCPSocket
PostPosted: Fri Jan 04, 2013 8:55 pm 
Offline

Joined: Fri Jan 04, 2013 8:48 pm
Posts: 1
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Sending binary Data with TCPSocket
PostPosted: Sun Jan 06, 2013 2:26 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
Im going to take a look on the net...believe I've come across an open source modbus implementation...

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Sending binary Data with TCPSocket
PostPosted: Sun Jan 06, 2013 3:20 pm 
Offline
User avatar

Joined: Sun Oct 28, 2012 4:54 am
Posts: 264
Location: Herts, UK
You could always call some python from within your RB apps

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

:wink:

_________________
Real Studio 2012 R2
SysInfo
BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD
& Yes it's me in the Avatar


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group