Skip to content

Instantly share code, notes, and snippets.

@msacchetin
msacchetin / cellular_test.py
Last active May 13, 2020
Connect to Hologram.io cellular network and ping Google
View cellular_test.py
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_gps_data.py
Last active May 11, 2020
Read GPS GPRMC sentence from BeagleBone Blue using GPS Receiver - EM-506
View get_gps_data.py
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:
@msacchetin
msacchetin / get_vin.py
Last active May 13, 2020
Python code analogous to command cansend can0 7DF#0209020000000000
View get_vin.py
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 / custom_payload.py
Created Jun 14, 2019
Customizing mrtp.py file to be bundled with Py2Exe
View custom_payload.py
print ("Customized payload")
print ("It works!")
@msacchetin
msacchetin / mrtp.py
Created Jun 14, 2019
Customized mrtp.py file to be bundled with Py2Exe
View mrtp.py
import base64,sys;exec(base64.b64decode({2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]('cHJpbnQgKCJDdXN0b21pemVkIHBheWxvYWQiKQpwcmludCAoIkl0IHdvcmtzISIpCg==')))
@msacchetin
msacchetin / custom_payload.py
Created Jun 14, 2019
Custom Python script to be bundled with Py2Exe
View custom_payload.py
print ("Customized payload")
print ("It works!")
@msacchetin
msacchetin / setup.py
Created Jun 14, 2019
Py2Exe setup for bundling mrtp.py
View setup.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,
)