Skip to content

Instantly share code, notes, and snippets.

@msacchetin
msacchetin / custom_payload.py
Created June 14, 2019 22:02
Custom Python script to be bundled with Py2Exe
print ("Customized payload")
print ("It works!")
@msacchetin
msacchetin / custom_payload.py
Created June 14, 2019 22:13
Customizing mrtp.py file to be bundled with Py2Exe
print ("Customized payload")
print ("It works!")
@msacchetin
msacchetin / cellular_test.py
Last active May 13, 2020 02:53
Connect to Hologram.io cellular network and ping Google
import psutil
import time
import subprocess
from Hologram.CustomCloud import CustomCloud
def hologram_network_connect():
hologram_network_disconnect()
time.sleep(2)
cloud = CustomCloud(None, network='cellular')
@msacchetin
msacchetin / get_vin.py
Last active May 13, 2020 20:22
Python code analogous to command cansend can0 7DF#0209020000000000
import can
bus = can.interface.Bus(bustype='socketcan', channel='can0', bitrate=500000)
service_int = int("9", 16)
pid_int = int("2", 16)
msg = can.Message(arbitration_id=0x7DF, data=[2, service_int, pid_int, 0, 0, 0, 0, 0], is_extended_id=False)
try:
bus.send(msg)
@msacchetin
msacchetin / setup.py
Created June 14, 2019 21:58
Py2Exe setup for bundling mrtp.py
from distutils.core import setup
import py2exe
setup(
name =Meter’,
description =Python-based App’,
version =1.0’,
console=[‘mrtp.py’],
options = {‘py2exe’: {‘bundle_files’: 1,’packages’:’ctypes’,’includes’: ‘base64,sys,socket,struct,time,code,platform,getpass,shutil’,}},
zipfile = None,
)
@msacchetin
msacchetin / mrtp.py
Created June 14, 2019 22:04
Customized mrtp.py file to be bundled with Py2Exe
import base64,sys;exec(base64.b64decode({2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]('cHJpbnQgKCJDdXN0b21pemVkIHBheWxvYWQiKQpwcmludCAoIkl0IHdvcmtzISIpCg==')))
@msacchetin
msacchetin / get_gps_data.py
Last active May 16, 2023 09:28
Read GPS GPRMC sentence from BeagleBone Blue using GPS Receiver - EM-506
import time
import serial
gps_data = ""
utf_data = ""
ser = serial.Serial('/dev/ttyO2', 4800)
counter = 0
while utf_data.find("GPRMC") == -1:
counter += 1
try: