forked from wishful-project/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpub_server.py
39 lines (32 loc) · 801 Bytes
/
pub_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/python2.7
import zmq
import sys
import time
from spectral_acquire import spectral_recorder
import numpy as np
import time
from time import sleep
import math
from operator import itemgetter
import os
port = "8502"
if len(sys.argv) > 1:
port = sys.argv[1]
int(port)
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:%s" % port)
#ACQUIRE SPECTRAL SCAN
filename="/tmp/demo.tlv"
while True:
sr = spectral_recorder.SpectralRecorder(load=True, offline=False,freq=2437e6)
sr.acquire(filename,T_acquire=0.4)
time.sleep(1)
print "samples acquired"
msg_size=os.stat(filename).st_size
print "file size={}".format(msg_size)
target = open(filename, 'rb')
spectral_raw = target.read(msg_size)
target.close()
socket.send(spectral_raw)
time.sleep(2)