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