Commit c876662b authored by Mikaël BRIDAY's avatar Mikaël BRIDAY
Browse files

script updated for ultrasound…

parent c90a1ef2
......@@ -19,7 +19,6 @@ void setup() {
/* main function */
int main(void) {
setup();
for(int i=0;i<1000;i++);
/* Infinite loop */
while (1) {
/* Add application code here */
......
......@@ -10,7 +10,10 @@ import sys,time
import threading
# Communication part
import struct
pipc_magic = 0xdeadbeef
pipc_gpio_magic = 0xdeadbeef
pipc_adc_magic = 0xcafecafe
pipc_serial_magic = 0xabcdef01
import posix_ipc as pipc
mq_to_qemu = pipc.MessageQueue("/to_qemu",flags=pipc.O_CREAT, read=False, write=True)
mq_from_qemu = pipc.MessageQueue("/from_qemu",flags=pipc.O_CREAT, read=True, write=False)
......@@ -85,14 +88,18 @@ window = MainWindow()
def receiver():
while True:
msg = mq_from_qemu.receive()
mg, changed_out, dir_mask,output,gpio = struct.unpack("=IHHHH",msg[0])
magic = struct.unpack("=I",msg[0][0:4]) #get magic value. return a tuple.
#print("mg=",mg," pin=",pin," gpio=",gpio," state=",state)
if mg != pipc_magic:
raise Exception("Wrong magic number in GPIO IPC message")
name = ['A','B','C','D','F']
if gpio < 5:
window.setGPIO(name[gpio],dir_mask,output) #TODO: thread safe?
#required if we get too much messages to let time for the UI.
if magic[0] == pipc_gpio_magic:
magic, changed_out, dir_mask,output,gpio = struct.unpack("=IHHHH",msg[0])
name = ['A','B','C','D','F']
if gpio < 5:
window.setGPIO(name[gpio],dir_mask,output) #TODO: thread safe?
elif magic[0] == pipc_serial_magic:
pass
else:
raise Exception("Wrong magic number in GPIO IPC message: 0x{val:08x}".format(val=magic[0]) )
#required if we get too many messages to let time for the UI.
time.sleep(.01)
window.show()
......
......@@ -12,6 +12,8 @@ import threading
import struct
pipc_gpio_magic = 0xdeadbeef
pipc_adc_magic = 0xcafecafe
pipc_serial_magic = 0xabcdef01
import posix_ipc as pipc
mq_to_qemu = pipc.MessageQueue("/to_qemu",flags=pipc.O_CREAT, read=False, write=True)
mq_from_qemu = pipc.MessageQueue("/from_qemu",flags=pipc.O_CREAT, read=True, write=False)
......@@ -181,14 +183,20 @@ window = MainWindow()
def receiver():
while True:
msg = mq_from_qemu.receive()
mg, changed_out, dir_mask,output,gpio = struct.unpack("=IHHHH",msg[0])
magic = struct.unpack("=I",msg[0][0:4]) #get magic value. return a tuple.
#print("mg=",mg," pin=",pin," gpio=",gpio," state=",state)
if mg != pipc_gpio_magic:
raise Exception("Wrong magic number in GPIO IPC message")
name = ['A','B','C','D','F']
if gpio < 5:
window.setGPIO(name[gpio],dir_mask,output) #TODO: thread safe?
#required if we get too much messages to let time for the UI.
if magic[0] == pipc_gpio_magic:
magic, changed_out, dir_mask,output,gpio = struct.unpack("=IHHHH",msg[0])
name = ['A','B','C','D','F']
if gpio < 5:
window.setGPIO(name[gpio],dir_mask,output) #TODO: thread safe?
elif magic[0] == pipc_serial_magic:
magic, char = struct.unpack("=II",msg[0])
#print('char {0:c}'.format(char))
window.serial.insertPlainText(chr(char & 0xff))
else:
raise Exception("Wrong magic number in GPIO IPC message: 0x{val:08x}".format(val=magic[0]) )
#required if we get too many messages to let time for the UI.
time.sleep(.01)
def warningPersistence():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment