sss7modem/software/python/test.py

40 lines
614 B
Python
Raw Normal View History

2016-12-22 17:50:02 +01:00
#!/usr/bin/env python2
from time import sleep
from sss7 import SSS7
def to_byte_list(data):
return [ord(c) for c in data]
def to_string(data):
data = [chr(c) for c in data]
return "".join(data)
def main():
SSS7.start("/dev/ttyUSB0")
while not SSS7.can_send() :
sleep(0.1)
SSS7.send(to_byte_list("Hello python"))
while not SSS7.can_send():
sleep(0.1)
if SSS7.send_failed():
print "Send failed"
2016-12-23 02:08:57 +01:00
while not SSS7.has_received():
sleep(0.1)
print to_string(SSS7.get_received())
2016-12-22 17:50:02 +01:00
SSS7.stop()
if __name__ == '__main__':
main()