Editing User:EmbeddedLinuxGuy

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
= table =
{| class="wikitable collapsible"
! Simple collapsible table
|-
| Lorem ipsum dolor sit amet
|}
= ssh public key =
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxmitrXxenyJDjEhVCNeBDMtV0+yuXGVrb0qO/e9LxiB0w255JvX/iDWtLqaeu7DriwK9yiCM6UXUp3gnhUUXIDvs5cljXRDlLbm9ziq5fumh0r+AvlDMRejFwxCSNuucY0/vkaY0Ow1CzlecixFjZ77tCygbqm/az++D0+KpRavyvLyVXiSpdEbJFKpq5RTdk4ht7DpMxHKJC7h3FCoNB9N3B7H+dUGmTx3JKwAJ5uHeOpV8wKrTQco/6SlROl2zBBIsllvbniYuBZ5uhK1qWc8CFEaH6yi4MM20SB/qQpCn/G/1/RdlW1Qks8sy5uMmSXP1FA0FtaRuhAi+gSoaDw== embeddedlinuxguy@gmail.com
= bio =
I mostly do programming for Linux and the Web, but also like to tinker with an Arduino and soldering iron when I have the chance.
I mostly do programming for Linux and the Web, but also like to tinker with an Arduino and soldering iron when I have the chance.
= art =
[[Media:Stars-small.svg|Stars SVG]]
=Stuff=
<pre>
import serial
import urllib
import sys
if sys.version_info >= (3, 0):
import urllib.request
gui = 0
else:
gui = 1
from time import strftime, gmtime, sleep
# mode 0=error, 1-5
# door 0=closed 1=open
# gate 0=closed 1=open
# laser beam 0=fine 1=interrupted
# wire 0=fine 1=interrupted
# keypad 0=nothing/1=good/2=bad password
# code string-of-digits (5 or more)
PAUSE_SERIAL = 0
if gui:
import wx
ID_START = wx.NewId()
class Frame(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self, None, title=title, size=(350,200))
panel = wx.Panel(self)
box = wx.BoxSizer(wx.VERTICAL)
m_text = wx.StaticText(panel, -1, "Box Shop Alarm Control")
m_text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
m_text.SetSize(m_text.GetBestSize())
box.Add(m_text, 0, wx.ALL, 10)
self.m_status = wx.StaticText(panel, -1, "")
self.m_open = wx.Button(panel, ID_START, "Start")
self.m_close = wx.Button(panel, wx.ID_CLOSE, "Stop")
self.m_buzz = wx.Button(panel, wx.ID_CLOSE, "Buzz")
self.m_close.Bind(wx.EVT_BUTTON, self.OnClose)
self.m_open.Bind(wx.EVT_BUTTON, self.OnStart)
self.m_buzz.Bind(wx.EVT_BUTTON, self.OnBuzz)
box.Add(self.m_open, 0, wx.ALL, 10)
box.Add(self.m_close, 0, wx.ALL, 10)
box.Add(self.m_buzz, 0, wx.ALL, 10)
panel.SetSizer(box)
panel.Layout()
self.m_close.Disable()
def OnClose(self, event):
self.RUN_SERIAL = 0
self.m_close.Disable()
self.m_open.Enable()
def OnStart(self, event):
self.m_open.Disable()
self.m_close.Enable()
self.handleSerial()
def OnBuzz(self, event):
self.RUN_SERIAL = 2
def handleSerial(self):
self.RUN_SERIAL = 1
ser = serial.Serial(2, 9600, timeout=1)
outputs = {'M': '0', 'D': '0', 'G': '0', 'B': '0', 'W': '0', 'K': '0', 'C': '0'}
while self.RUN_SERIAL:
if self.RUN_SERIAL == 2:
self.m_status.SetLabel("WE ARE BUZZING!!!!")
s = ".D1"
if (s):
ser.write(s)
self.m_status.SetLabel("We buzzed.")
self.RUN_SERIAL = 1
else:
value = ser.readline().decode('utf-8')
if value:
for v in value.strip('{}').split('}{'):
outputs[v[0]] = v[1:]
url = "http://www.waywardengineer.com/boxshop/alarmapi.php?"
for k, v in outputs.items():
url += k + '=' + v + '&'
outputs['K'] = '0'
outputs['C'] = '0'
self.m_status.SetLabel(url)
#print(url)
try:
if sys.version_info >= (3, 0):
f = urllib.request.urlopen(url)
else:
f = urllib.urlopen(url)
s = f.read()
#print (s)
if (s):
ser.write(s)
except Exception as inst:
print("Got an error contacting the web " + strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()))
print(type(inst))
print(inst.args)
print(inst)
sleep(1)
wx.Yield()
app = wx.App(redirect=True)
top = Frame("Box Shop Alarm Control")
top.Show()
app.MainLoop()
else:
class SerialWebBridge:
def handleSerial(self):
self.RUN_SERIAL = 1
ser = serial.Serial(2, 9600, timeout=1)
outputs = {'M': '0', 'D': '0', 'G': '0', 'B': '0', 'W': '0', 'K': '0', 'C': '0'}
while self.RUN_SERIAL:
value = ser.readline().decode('utf-8')
if value:
for v in value.strip('{}').split('}{'):
outputs[v[0]] = v[1:]
url = "http://www.waywardengineer.com/boxshop/alarmapi.php?"
for k, v in outputs.items():
url += k + '=' + v + '&'
outputs['K'] = '0'
outputs['C'] = '0'
print(url)
try:
if sys.version_info >= (3, 0):
f = urllib.request.urlopen(url)
else:
f = urllib.urlopen(url)
s = f.read()
print (s)
if (s):
ser.write(s)
except Exception as inst:
print("Got an error contacting the web " + strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()))
print(type(inst))
print(inst.args)
print(inst)
sleep(1)
bridge = SerialWebBridge()
bridge.handleSerial()
</pre>
Please note that all contributions to Noisebridge are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Noisebridge:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)