Skip to content

Instantly share code, notes, and snippets.

@yogiblue
Last active July 12, 2019 08:21
Show Gist options
  • Save yogiblue/e4c2f605d955df9e2c5a2bc9f0dc3f12 to your computer and use it in GitHub Desktop.
Save yogiblue/e4c2f605d955df9e2c5a2bc9f0dc3f12 to your computer and use it in GitHub Desktop.
import serial
import time
import pyperclip
import pyautogui
print "0Haus Pioneer PX224/E data reciever program"
print "Press print on the scales and this software will paste it"
print "wherever your cursor has focus"
s = serial.Serial()
foundPort = False
s.port ='COM3'
try:
s.open()
foundPort = True
except:
print "!! Could not open serial port on COM3"
foundPort = False
if foundPort == False:
s.port ='COM4'
try:
s.open()
foundPort = True
except:
print "!! Could not open serial port on COM4"
foundPort = False
if foundPort == False:
s.port ='COM1'
try:
s.open()
foundPort = True
except:
print "!! Could not open serial port on COM1"
foundPort = False
if foundPort == False:
s.port ='COM2'
try:
s.open()
foundPort = True
except:
print "!! Could not open serial port on COM2"
foundPort = False
if foundPort == False:
print "!! WARNING"
print "!! Could not open serial port on any COM, try plugging the scales in"
print "!! Aborting"
time.sleep(5)
quit()
if s.is_open == False:
time.sleep(10)
print "Could not detect COM, try plugging the scales in"
quit()
print "Waiting"
while True:
size = s.inWaiting()
buffer = s.read(size)
if size>0:
start = buffer.find('Net:')
end = buffer.find('g N')
if end>start+5:
number = buffer[start+5:end]
print "Read Net Value " + number.strip()
pyperclip.copy(number.strip())
pyautogui.hotkey('ctrl','v')
else:
print "I read some data but I don't know what it is. Contact Chris"
time.sleep(1)
start=0
end=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment