Skip to content

Instantly share code, notes, and snippets.

View frankgould's full-sized avatar

Frank Gould frankgould

  • Orlando, Florida
View GitHub Profile
@frankgould
frankgould / wifi-test.py
Last active December 17, 2018 22:35
using to determine wifi strength and display icon representation
import subprocess
temp = subprocess.Popen(args=['iwconfig wlan0 | grep -i quality'], stdout=subprocess.PIPE, shell=True)
wlan0_val, err = temp.communicate()
wlan0_strength = str(wlan0_val)
wlan0_strength = 'bb Link Quality=5/50 Signal level=-51 dBm \n'
cmp=wlan0_strength[25:33]
i=1
while cmp[i]!='/':
i += 1
cmp_num = cmp[:i]
@frankgould
frankgould / battery_server.py
Created January 3, 2019 17:02
Rover Battery Capacity Communications Server code
#!/usr/bin/env python3
"""Server for multithreaded (asynchronous) chat application."""
from socket import AF_INET, socket, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR
from threading import Thread
import logging
from datetime import datetime
log_file = '/home/rover_logs/comm_server-log-' + datetime.now().strftime("%m-%d-%y") + '.txt'
logging.basicConfig(filename=log_file,level=logging.DEBUG)
logging.info('==================== Rover Battery Capacity Communications Server Logging Started ' + datetime.now().strftime("%m-%d-%y %H:%M:%S"))
@frankgould
frankgould / config.txt
Created March 1, 2019 15:01
Arch Linux ARM config.txt
# Uncomment some or all of these to enable the optional hardware interfaces
# Params:
# i2c_arm Set to "on" to enable the ARM's i2c interface
# (default "off")
# i2c_vc Set to "on" to enable the i2c interface
# usually reserved for the VideoCore processor
# (default "off")
# i2c_arm_baudrate Set the baudrate of the ARM's i2c interface
# (default "100000")
# i2c_vc_baudrate Set the baudrate of the VideoCore i2c interface
@frankgould
frankgould / screenmanagertest.py
Last active August 9, 2019 21:07
This is the test app used to test and report on memory usage. Due to previous versions of Raspbian releases with graphics driver memory leaks, this code has been tested successfully with the latest version 4.19 named Buster and only runs without lockup with screen resolution 800x600. Any higher resolution and fullscreen lock up.
#!/usr/bin/env python3
import glob
import os
#os.environ['KIVY_GRAPHICS'] = 'gles'
#os.environ['KIVY_WINDOW'] = 'sdl2'
from datetime import datetime
import time, sys, signal
import atexit
@frankgould
frankgould / btuart
Last active January 23, 2022 20:34
RPi4B files for bluetooth headsets on Arch Linux ARM 4.19
#!/bin/sh
HCIATTACH=/usr/bin/hciattach
if grep -q "Pi 4" /proc/device-tree/model; then
BDADDR=
else
SERIAL=`cat /proc/device-tree/serial-number | cut -c9-`
B1=`echo $SERIAL | cut -c3-4`
B2=`echo $SERIAL | cut -c5-6`
B3=`echo $SERIAL | cut -c7-8`
@frankgould
frankgould / gimbal.py
Created October 9, 2019 10:45
Server for multithreaded (asynchronous) chat application
#!/usr/bin/env python3
"""Server for multithreaded (asynchronous) chat application."""
from socket import AF_INET, socket, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR
from threading import Thread
from datetime import datetime
import logging, atexit, time
log_file = '/home/rover_logs/comm_server-log-' + datetime.now().strftime("%m-%d-%y") + '.txt'
logging.basicConfig(filename=log_file,level=logging.DEBUG)
logging.info('===== Rover Gimbal Communications Server Logging Started ' + datetime.now().strftime("%m-%d-%y %H:%M:%S"))
@frankgould
frankgould / rover-libclient.py
Last active November 29, 2019 14:19
This is the local rover client's library.
#!/usr/bin/env python3
# rover_libclient.py is the REMOTE socket library and Message class
import sys, selectors, json, struct
class Message:
def __init__(self, selector, sock, addr, name, request):
self.selector = selector
self.sock = sock
self.addr = addr
@frankgould
frankgould / rover_client.py
Last active November 29, 2019 14:18
The primary app to handle the client socket interface to the rover server.
#!/usr/bin/env python3
# rover-client.py is the Rover client app to receive ping from Remote and respond with ACK
import sys, socket, selectors, traceback, time
import rover_libclient
from datetime import datetime
sel = selectors.DefaultSelector()
# Connection startup - Socket and Message Object Creation
#!/usr/bin/env python3
# gimbal-client.py is the Rover client app to receive commands from Remote and respond with ACK/WAK
## attribution: https://realpython.com/python-sockets/
from __future__ import division
from Raspi_PWM_Servo_Driver import PWM
from datetime import datetime, timedelta
import sys, socket, selectors, traceback, time, atexit, logging
import configparser
@frankgould
frankgould / rover-server.py
Created December 9, 2019 14:37
This is the original Goddard rover prototype 1 code that will be separated into device individual modules: Recorder, Gimbal, Battery, and Motors.
#!/usr/bin/python3
#app name: rover-server.py
from __future__ import division
from datetime import datetime
import time, curses
import PiMotor
import gimbal
import subprocess
import os, sys