libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
sos.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
16 
17 from libpruio import *
18 import time
19 
20 
21 PIN = 24
22 
23 pinmode = 0
24 
25 Kurz = 0.15
26 
27 Lang = 0.35
28 
29 
30 def MCode(dur):
31  pruio_gpio_setValue(io, PIN, 128 + pinmode) # set on
32  time.sleep(dur)
33  pruio_gpio_setValue(io, PIN, pinmode) # set off
34  time.sleep(.15)
35 
36 
37 def out_S():
38  MCode(Kurz)
39  MCode(Kurz)
40  MCode(Kurz)
41 
42 
43 def out_O():
44  MCode(Lang)
45  MCode(Lang)
46  MCode(Lang)
47 
48 
49 io = pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0)
50 try:
51 
52  IO = io.contents
53  if IO.Errr: raise AssertionError("pruio_new failed (%s)" % IO.Errr)
54 
55  pinmode = IO.BallConf[PIN]
56  if pruio_config(io, 1, 0x1FE, 0, 4): # upload settings, start IO mode
57  raise AssertionError("config failed (%s)" % IO.Errr)
58  print("watch SOS code on user LED 3 (near ethernet connector)")
59  print("execute the following command to get rid of mmc1 triggers")
60  print(" sudo su && echo none > /sys/class/leds/beaglebone:green:usr3/trigger && echo 0 > /sys/class/leds/beaglebone:green:usr3/brightness && exit")
61  print("press <Ctrl>-C to quit")
62  try:
63  while True:
64  out_S()
65  out_O()
66  out_S()
67  time.sleep(1.5)
68  except KeyboardInterrupt:
69  pass
70  pruio_gpio_setValue(io, PIN, pinmode) # reset LED
71 finally:
72  pruio_destroy(io)
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().
pruIo * pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD)
Wrapper function for the constructor PruIo::PruIo().
void pruio_destroy(pruIo *Io)
Wrapper function for the destructor PruIo::~PruIo().
char * pruio_gpio_setValue(pruIo *Io, uint8 Ball, uint8 Modus)
Wrapper function for GpioUdt::setValue().