Created
July 30, 2019 21:03
-
-
Save daniestevez/f97cefc1d76af9df83662cfbc4f56ae4 to your computer and use it in GitHub Desktop.
Example LimeRFE WSRP PTT control script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
from ctypes import * | |
import sys | |
import os | |
import time | |
import datetime | |
import limeRFE_H as LH | |
libLimeSuite = ctypes.cdll.LoadLibrary('/usr/local/lib64/libLimeSuite.so') | |
baudrate = 9600 | |
# Open port | |
fd = libLimeSuite.LIMERFE_Open(c_char_p(b"/dev/ttyUSB0"), c_int(baudrate)); | |
if (fd == -1): | |
print(stderr, "Error initializing serial port\n") | |
exit(1) | |
cinfo = (c_ubyte*4)() | |
print("Port opened; fd =", fd) | |
# Configure LimeRFE to use channel HAM 2m channel in receive mode. | |
# Transmit output is routed to TX output. Notch is off. Attenuation is 0. | |
#libLimeSuite.LIMERFE_Configure(c_int(LH.LIMERFE_USB), c_int(0), c_int(0), c_int(fd), c_int(LH.CID_HAM_0030), c_int(LH.TX2TXRX_INDEX_TX), c_int(LH.NOTCH_VALUE_OFF), c_int(0)) | |
#time.sleep(1.0) | |
# Change mode to transmit | |
#libLimeSuite.LIMERFE_Mode(c_int(LH.LIMERFE_USB), c_int(0), c_int(0), c_int(fd), c_int(LH.RFE_MODE_TX)) | |
while True: | |
t = datetime.datetime.utcnow() | |
s = t.minute * 60 + t.second | |
x = s % (4 * 60) | |
print(t.isoformat()) | |
if x > 4 * 60 - 3 or x < 2 * 60: | |
print('PTT on') | |
libLimeSuite.LIMERFE_Mode(c_int(LH.LIMERFE_USB), c_int(0), c_int(0), c_int(fd), c_int(LH.RFE_MODE_TX)) | |
else: | |
print('PTT off') | |
libLimeSuite.LIMERFE_Mode(c_int(LH.LIMERFE_USB), c_int(0), c_int(0), c_int(fd), c_int(LH.RFE_MODE_RX)) | |
time.sleep(1.0) | |
#time.sleep(1.0) | |
# Reset LimeRFE | |
#libLimeSuite.LIMERFE_Reset(c_int(fd)) | |
# Close port | |
libLimeSuite.LIMERFE_Close(c_int(fd)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment