Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a089a38a1 | ||
|
|
c68c360abf | ||
|
|
6843dc9714 | ||
|
|
e4d10a9f13 | ||
|
|
187390e375 | ||
|
|
a7e38aedb7 |
No files matched your search
@@ -0,0 +1,12 @@
|
||||
# Lora 2 Serial
|
||||
## Mapping rfm9x SPI Device to a Serial File Interface for usage with AX.25 Kiss
|
||||
|
||||
creates /tmp/rfmtty and /tmp/rfmtty_client
|
||||
|
||||
Attach using kissattach /tmp/rfmtty_client ax0 IP_ADDRESS
|
||||
|
||||
with configured axports
|
||||
|
||||
https://github.com/dmahony/LoRa-AX25-IP-Network/wiki/Installation-Instructions
|
||||
|
||||
http://packet-radio.info/index.php?id=packet-radio-unter-linux-mit-linpac
|
||||
@@ -1,35 +0,0 @@
|
||||
import os, subprocess, serial, time
|
||||
|
||||
# this script lets you emulate a serial device
|
||||
# the client program should use the serial port file specifed by client_port
|
||||
|
||||
# if the port is a location that the user can't access (ex: /dev/ttyUSB0 often),
|
||||
# sudo is required
|
||||
|
||||
class SerialEmulator(object):
|
||||
def __init__(self, device_port='./ttydevice', client_port='./ttyclient'):
|
||||
self.device_port = device_port
|
||||
self.client_port = client_port
|
||||
cmd=['/usr/bin/socat','-d','-d','PTY,link=%s,raw,echo=0' %
|
||||
self.device_port, 'PTY,link=%s,raw,echo=0' % self.client_port]
|
||||
self.proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
time.sleep(1)
|
||||
self.serial = serial.Serial(self.device_port, 9600, rtscts=True, dsrdtr=True)
|
||||
self.err = ''
|
||||
self.out = ''
|
||||
|
||||
def write(self, out):
|
||||
self.serial.write(out)
|
||||
|
||||
def read(self):
|
||||
line = ''
|
||||
while self.serial.inWaiting() > 0:
|
||||
line += self.serial.read(1)
|
||||
return line
|
||||
|
||||
def __del__(self):
|
||||
self.stop()
|
||||
|
||||
def stop(self):
|
||||
self.proc.kill()
|
||||
self.out, self.err = self.proc.communicate()
|
||||
@@ -3,14 +3,9 @@ import serial, subprocess, time
|
||||
import busio
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
import board
|
||||
#import adafruit_rfm69
|
||||
import adafruit_rfm9x
|
||||
|
||||
CS = DigitalInOut(board.CE1)
|
||||
RESET = DigitalInOut(board.D25)
|
||||
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)
|
||||
from pyLoraRFM9x import LoRa, ModemConfig
|
||||
|
||||
|
||||
addr = '/tmp/rfmtty'
|
||||
addr_client = '/tmp/rfmtty_client'
|
||||
@@ -22,23 +17,23 @@ time.sleep(1)
|
||||
|
||||
ser = serial.serial_for_url(addr)
|
||||
|
||||
def on_recv(payload):
|
||||
print(f'Received lora data: {payload.message}')
|
||||
ser.write(payload.message)
|
||||
|
||||
lora_address = 2
|
||||
lora = LoRa(1, 5, lora_address, reset_pin = 25, modem_config=ModemConfig.Bw125Cr45Sf128, tx_power=14, receive_all=True)
|
||||
lora.on_recv = on_recv
|
||||
|
||||
while True:
|
||||
packet = None
|
||||
packet = rfm.receive()
|
||||
ser_data = bytearray()
|
||||
while ser.inWaiting() > 0:
|
||||
while ser.inWaiting() > 0 and len(ser_data) <= 248:
|
||||
recieved_byte = ser.read(1)
|
||||
ser_data += recieved_byte
|
||||
if ser_data == b'':
|
||||
pass
|
||||
else:
|
||||
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)
|
||||
lora.send(bytes(ser_data), 255)
|
||||
|
||||
socat_proc.kill()
|
||||
Reference in new issue
Block a user