added socat command
This commit is contained in:
parent
5eb20accb6
commit
223ce16bbe
14
main.py
14
main.py
|
@ -1,4 +1,4 @@
|
|||
import serial
|
||||
import serial, subprocess, time
|
||||
|
||||
import busio
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
|
@ -12,8 +12,14 @@ spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
|
|||
#rfm = adafruit_rfm69.RFM69(spi, CS, RESET, 868.0)
|
||||
rfm = adafruit_rfm9x.RFM9x(spi, CS, RESET, 868.0)
|
||||
|
||||
addr = '/tmp/rfmtty'
|
||||
addr_client = '/tmp/rfmtty_client'
|
||||
|
||||
cmd=['/usr/bin/socat','-d','-d','PTY,link=%s,raw,echo=0' %
|
||||
addr, 'PTY,link=%s,raw,echo=0' % addr_client]
|
||||
socat_proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
time.sleep(1)
|
||||
|
||||
addr = '/tmp/virttty'
|
||||
ser = serial.serial_for_url(addr)
|
||||
|
||||
|
||||
|
@ -27,10 +33,12 @@ while True:
|
|||
if ser_data == b'':
|
||||
pass
|
||||
else:
|
||||
print(f'Received sers data: {ser_data}')
|
||||
print(f'Received serial data: {ser_data}')
|
||||
rfm.send(ser_data)
|
||||
if packet is None:
|
||||
pass
|
||||
else:
|
||||
print(f'Received lora byte: {packet}')
|
||||
ser.write(packet)
|
||||
|
||||
socat_proc.kill()
|
Loading…
Reference in New Issue