P3 receiving and decoding

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ultravibe
Posts: 65
Joined: Sat Jan 17, 2015 12:06 pm

P3 receiving and decoding

Post by Ultravibe » Mon Oct 05, 2015 8:35 pm

Hello everybody!!!
I interested of some interaction with specific device using p3 protocol. I found out that device broadcasts UDP datagrams. But these datagrams are binary. How can I decode it in case I know what means each byte?
Of course I want to do it with LiveCode!!!
Thanks!

Ultravibe
Posts: 65
Joined: Sat Jan 17, 2015 12:06 pm

Re: P3 receiving and decoding

Post by Ultravibe » Mon Oct 05, 2015 9:55 pm

It seems to me that i should use something like this:

Code: Select all

on openCard
open datagram socket "192.168.0.203:5403" --it's IP address and port of device
accept datagram connecitons on port 5403 with message "DataRecieved"
end openCard
on DataRecieved curIP,curData
put textDecode(curData,"???") into curData
--what kind of encoding should i use for curData if i know that UDP message is binary??? ASCII?
end DataRecieved

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: P3 receiving and decoding

Post by FourthWorld » Mon Oct 05, 2015 11:31 pm

The textDecode function is useful for coercing tet encoding schemes. For translating binary data to and from various formats see the binaryDecode function.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Ultravibe
Posts: 65
Joined: Sat Jan 17, 2015 12:06 pm

Re: P3 receiving and decoding

Post by Ultravibe » Tue Oct 06, 2015 6:31 am

FourthWorld wrote:The textDecode function is useful for coercing tet encoding schemes. For translating binary data to and from various formats see the binaryDecode function.
Thanks, I'll try it! And with receiving messages everything is ok? Can I use accept command?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: P3 receiving and decoding

Post by FourthWorld » Tue Oct 06, 2015 6:34 am

I'm completely unfamiliar with P3, so that's where you'll be teaching me. :) Give accept a try and report back what you find.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Ultravibe
Posts: 65
Joined: Sat Jan 17, 2015 12:06 pm

Re: P3 receiving and decoding

Post by Ultravibe » Tue Oct 06, 2015 7:08 am

Richard, I have some problems: number of detected device is presented by 4 hex bytes. How to transform it to "normal" number? I saw that guys are taking hex bytes from last to first and do something with it. Can you say what exactly they does?
P.S. The same thing they does with received time that also is presented by four hex bytes

Ultravibe
Posts: 65
Joined: Sat Jan 17, 2015 12:06 pm

Re: P3 receiving and decoding

Post by Ultravibe » Tue Oct 06, 2015 12:29 pm

Gotcha!
I found how to parse messages. The only task now - is to recieve these messages from device)))))

Post Reply