Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Problem about use CR6 to recive UDP broadcast data


Kael_BTS Sep 9, 2019 01:17 AM

Hi,I have got a CR6(IP:192.168.1.95) ,Within the LAN,the LAN getway is "192.168.1.1", I use the software" UDP TOOL "to send the UDP data to IP :"192.168.1.255"  (the broadcast IP in the LAN),PORT:65000.If you use the " UDP TOOL" to  listen the port 65000 with another IP(192.168.1.100),you will recive the UDP data.But if you choose the CR6 to listen the port 65000,you will recive nothing. 

This is the code,

BeginProg


outstring = "hello"
socket_udp = UDPOpen ("127.0.0.1",65000,100,0)


Scan (1,Sec,0,0)

SerialIn (instring,socket_udp,100,"",100)
'SerialOut (socket_udp,OutString,"",0,0)


'Enter other measurement instructions
'Call Output Tables
'Example:


CallTable Test
NextScan
EndProg

Could you Pls. point out what`s wrong with it?


JDavis Sep 9, 2019 01:29 PM

Use a blank address of  ""  (double quotes only) to open a port for listening. 


Kael_BTS Sep 10, 2019 02:58 AM

>I have followed your suggest.But can`t recive the UDP data.

 

'CR6 Series Datalogger

'For programming tips, copy this address to your browser
'search window:https://www.campbellsci.com/videos/datalogger-programming
'To create a different opening program template, type in new
'instructions and select Template | Save as Default Template
'Date:
'Program author:

'Declare Constants
'Example:
'CONST PI = 3.141592654 or Const PI = 4*ATN(1)

'Declare Public Variables
'Example:
Public PTemp, Batt_volt
Public socket_udp As Long 
Public instring As String * 80
Public RecVar As String * 80
Public outstring As String * 80
'Declare Private Variables
Public NBytesReturned
'Example:

'Define Data Tables
DataTable (Test,1,-1) 'Set table size to # of records, or -1 to autoallocate.
	DataInterval (0,15,Sec,10)
	Minimum (1,batt_volt,FP2,False,False)
	Sample (1,PTemp,FP2)
EndTable

'Define Subroutines
'Sub
	'EnterSub instructions here


'EndSub

'Main Program
BeginProg
  OutString = "hello"
  socket_udp = UDPOpen ("",60000,25,0)
	Scan (1,Sec,0,0)
		PanelTemp (PTemp,15000)
		Battery (Batt_volt)
		
    'SerialIn (instring,socket_udp,100,&h24,12)
    SerialInRecord (socket_udp,instring,&h47,10,0,NBytesReturned,01)
'SerialOut (socket_udp,OutString,"",0,0)
		'Enter other measurement instructions
		'Call Output Tables
		'Example:


		CallTable Test
	NextScan
EndProg

 

Log in or register to post/reply in the forum.