otsdaq_demo  v2_05_02_indev
udp_send_artdaq.py
1 #!/usr/bin/env python
2  # This file (udp_send_artdaq.py) was created by Ron Rechenmacher <ron@fnal.gov> on
3  # Jan 15, 2015. "TERMS AND CONDITIONS" governing this file are in the README
4  # or COPYING file. If you do not have such a file, one can be obtained by
5  # contacting Ron or Fermi Lab in Batavia IL, 60510, phone: 630-840-3000.
6  # $RCSfile: .emacs.gnu,v $
7  # rev="$Revision: 1.23 $$Date: 2012/01/23 15:32:40 $";
8 
9 import sys
10 import socket
11 USAGE='send host:port seqnum'
12 
13 # first byte is cmd
14 # 2nd byte is seqnum (yes, just 8 bits)
15 # rest is data (up to 1498)
16 
17 buf=''
18 
19 def main(argv):
20  print('len(argv)=%d'%(len(argv),))
21  if len(argv) != 3: print(USAGE); sys.exit()
22  node,port = argv[1].split(':')
23  buf='x'
24  buf+=chr(int(argv[2])&0xff)
25  buf+="This is the ARTDAQ UDP test string. It contains exactly 109 characters, making for a total size of 111 bytes."
26  s = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
27  s.sendto( buf, (node,int(port)) )
28  pass
29 
30 
31 if __name__ == "__main__": main(sys.argv)