Reading TCP packets in Omnis

Jef Leys | Desim jef.leys at desim.be
Wed Feb 28 15:47:10 UTC 2024


Hi,

This is code to communicate with a modbus device

GCadgisIP is character
SocketUit is character
binBuffer is Binary
Buffer is Binary
AntwoordLengte is Number, floating
Antwoord is Character

If you use Modbus, do not forget to append the CRC test.

Jef Leys


> Op 28 feb. 2024, om 16:21 heeft jim jpcr.com <jim at jpcr.com> het volgende geschreven:
> 
> Hi Jef,
> 
> This looks promising!  Could you also send your variable definitions?
> 
> Thanks,
> 
> Jim
> 
> --
> Jim Pistrang
> JP Computer Resources
> 413-237-5710
> <https://jpcr.com>
> 
> On Feb 28, 2024, at 10:12 AM, Jef Leys | Desim <jef.leys at desim.be> wrote:
> 
> Hi,
> 
> Some sample code that works.
> 
> 
> TCPConnect (FGebouw.GCadisIP,502) Returns socketUit
> If flag true
> 
> Calculate binBuffer as binfromhex(FullString)
> TCPSend (socketUit,binBuffer) Returns return
> If flag true
> 
> TCPReceive (socketUit,buffer) Returns AntwoordLengte
> If flag true
> 
> Calculate Antwoord as bintohex(buffer)
> End If
> End If
> End If
> TCPClose (socketUit)
> 
> 
> Jef Leys
> 
> Op 28 feb. 2024, om 16:09 heeft jim jpcr.com <jim at jpcr.com> het volgende geschreven:
> 
> Hi $List,
> 
> I’m struggling to read incoming TCP packets in Omnis.  I’ve attempted to write code using the various TCP commands, but with no success (and much head banging).
> 
> Does anyone have some sample code they can send me?
> 
> My code needs to listen for a packet on a specific port, and when it comes in it will call a method to write packet data to a database table and then go back to listening.
> 
> Thanks,
> 
> Jim
> 
> 
> 
> --
> Jim Pistrang
> JP Computer Resources
> 413-237-5710
> <https://jpcr.com>
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 



More information about the omnisdev-en mailing list