Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
itii-mac-tp-etu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mikaël BRIDAY
itii-mac-tp-etu
Commits
c876662b
Commit
c876662b
authored
Nov 24, 2020
by
Mikaël BRIDAY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
script updated for ultrasound…
parent
c90a1ef2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
16 deletions
+30
-16
lab2/main.c
lab2/main.c
+0
-1
virtual/qemu_io.py
virtual/qemu_io.py
+15
-8
virtual/stepper.py
virtual/stepper.py
+15
-7
No files found.
lab2/main.c
View file @
c876662b
...
...
@@ -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 */
...
...
virtual/qemu_io.py
View file @
c876662b
...
...
@@ -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
()
m
g
,
changed_out
,
dir_mask
,
output
,
gpio
=
struct
.
unpack
(
"=IHHHH"
,
msg
[
0
])
m
agic
=
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
()
...
...
virtual/stepper.py
View file @
c876662b
...
...
@@ -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
()
m
g
,
changed_out
,
dir_mask
,
output
,
gpio
=
struct
.
unpack
(
"=IHHHH"
,
msg
[
0
])
m
agic
=
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
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment