Page 1 of 1
					
				P3 receiving and decoding
				Posted: Mon Oct 05, 2015 8:35 pm
				by Ultravibe
				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!
			 
			
					
				Re: P3 receiving and decoding
				Posted: Mon Oct 05, 2015 9:55 pm
				by Ultravibe
				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
 
			 
			
					
				Re: P3 receiving and decoding
				Posted: Mon Oct 05, 2015 11:31 pm
				by FourthWorld
				The textDecode function is useful for coercing tet encoding schemes.  For translating binary data to and from various formats see the binaryDecode function.
			 
			
					
				Re: P3 receiving and decoding
				Posted: Tue Oct 06, 2015 6:31 am
				by Ultravibe
				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?
 
			 
			
					
				Re: P3 receiving and decoding
				Posted: Tue Oct 06, 2015 6:34 am
				by FourthWorld
				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.
 
			 
			
					
				Re: P3 receiving and decoding
				Posted: Tue Oct 06, 2015 7:08 am
				by Ultravibe
				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
			 
			
					
				Re: P3 receiving and decoding
				Posted: Tue Oct 06, 2015 12:29 pm
				by Ultravibe
				Gotcha!
I found how to parse messages. The only task now - is to recieve these messages from device)))))