Home AMX User Forum AMX Technical Discussion

UDP triggers event twice

Is it known?
PROGRAM_NAME='main'
DEFINE_DEVICE
dvUDP = 0:2:1
vdvTest = 36888:1:0

DEFINE_CONSTANT
CHAR UDP_MESSAGE[] = {$49,$51,$00,$00,$00,$14,$00,$07,$01,
$00,$fa,$64,$00,$01,$39,$6e,$00,$01,$0b,$c4}

DEFINE_VARIABLE
VOLATILE CHAR IPUDP[] = '192.168.1.82'

DEFINE_START
IP_CLIENT_OPEN(dvUDP.port, IPUDP, 5600, IP_UDP_2WAY )

DEFINE_EVENT
CHANNEL_EVENT[vdvTest, 1]
{
	ON:
	{
		SEND_STRING dvUDP, UDP_MESSAGE
	}
}

DATA_EVENT[dvUDP]
{
	STRING:
	{
		LOCAL_VAR INTEGER numTriggers
		LOCAL_VAR CHAR	the_data[30]
		
		the_data = DATA.TEXT
		numTriggers++
		SEND_STRING 0, ITOA(numTriggers)
		}
	
}
I guess you'd need something that speaks UDP to try it out your self.

Comments

  • viningvining Posts: 4,368
    Might just mean the data being returned doesn't all arrive at once so you get 2 or more string events. I know when web scrapping you can trigger multiple sting events for a single get request because the max bytes that can be return in one chunk (MTU) for ethernet connection is 1500. So if you have a web page that returns 40k it going to trigger a lot of string events.

    Now I've never done anything with UPD but it should be the same although it doesn't look as if you're expecting more thasn 30 byte in the_data[30] so maybe your device just studders. Are you getting the same strings twice? Maybe you shoulod concatenate your incoming data;
    the_data = "the_data ,DATA.TEXT" ;
    
    Thread w/ MTU info: http://amxforums.com/showthread.php?t=4406&highlight=web+scrapping
Sign In or Register to comment.