Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iggy
firmware
Compare revisions
master to fpletz/firmware-feat/run-py
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
iggy/firmware
Select target project
No results found
fpletz/firmware-feat/run-py
Select Git revision
Swap
Target
card10/firmware
Select target project
card10/firmware
annejan/firmware
astro/firmware
fpletz/firmware
gerd/firmware
fleur/firmware
swym/firmware
l/firmware
uberardy/firmware
wink/firmware
madonius/firmware
mot/firmware
filid/firmware
q3k/firmware
hauke/firmware
Woazboat/firmware
pink/firmware
mossmann/firmware
omniskop/firmware
zenox/firmware
trilader/firmware
Danukeru/firmware
shoragan/firmware
zlatko/firmware
sistason/firmware
datenwolf/firmware
bene/firmware
amedee/firmware
martinling/firmware
griffon/firmware
chris007/firmware
adisbladis/firmware
dbrgn/firmware
jelly/firmware
rnestler/firmware
mh/firmware
ln/firmware
penguineer/firmware
monkeydom/firmware
jens/firmware
jnaulty/firmware
jeffmakes/firmware
marekventur/firmware
pete/firmware
h2obrain/firmware
DooMMasteR/firmware
jackie/firmware
prof_r/firmware
Draradech/firmware
Kartoffel/firmware
hinerk/firmware
abbradar/firmware
JustTB/firmware
LuKaRo/firmware
iggy/firmware
ente/firmware
flgr/firmware
Lorphos/firmware
matejo/firmware
ceddral7/firmware
danb/firmware
joshi/firmware
melle/firmware
fitch/firmware
deurknop/firmware
sargon/firmware
markus/firmware
kloenk/firmware
lucaswerkmeister/firmware
derf/firmware
meh/firmware
dx/card10-firmware
torben/firmware
yuvadm/firmware
AndyBS/firmware
klausdieter1/firmware
katzenparadoxon/firmware
xiretza/firmware
ole/firmware
techy/firmware
thor77/firmware
TilCreator/firmware
fuchsi/firmware
dos/firmware
yrlf/firmware
PetePriority/firmware
SuperVirus/firmware
sur5r/firmware
tazz/firmware
Alienmaster/firmware
flo_h/firmware
baldo/firmware
mmu_man/firmware
Foaly/firmware
sodoku/firmware
Guinness/firmware
ssp/firmware
led02/firmware
Stormwind/firmware
arist/firmware
coon/firmware
mdik/firmware
pippin/firmware
royrobotiks/firmware
zigot83/firmware
mo_k/firmware
106 results
master
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
feat(tools): add run.py to execute python files via serial
· 72424267
fpletz
authored
5 years ago
72424267
improved handling of the serial file transfer and communication
· e710be7e
iggy
authored
5 years ago
e710be7e
add tarball upload support and cleanups
· 466a3833
fpletz
authored
5 years ago
466a3833
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
default.nix
+1
-0
1 addition, 0 deletions
default.nix
tools/run.py
+111
-0
111 additions, 0 deletions
tools/run.py
with
112 additions
and
0 deletions
default.nix
View file @
466a3833
...
@@ -22,6 +22,7 @@ in stdenv.mkDerivation rec {
...
@@ -22,6 +22,7 @@ in stdenv.mkDerivation rec {
ninja
ninja
py
py
py
.
pkgs
.
pillow
py
.
pkgs
.
pillow
py
.
pkgs
.
pyserial
];
];
src
=
./.
;
src
=
./.
;
buildCommand
=
''
buildCommand
=
''
...
...
This diff is collapsed.
Click to expand it.
tools/run.py
0 → 100755
View file @
466a3833
#!/usr/bin/env python3
# or using nix-shell
#!/usr/bin/env nix-shell
#! nix-shell -i python3 -p "python3.withPackages (ps: [ ps.pyserial ])"
import
sys
import
os.path
import
base64
import
argparse
import
tarfile
import
serial
parser
=
argparse
.
ArgumentParser
(
description
=
"
Executes python scripts on card10
"
)
parser
.
add_argument
(
"
-r
"
,
"
--run
"
,
required
=
False
,
type
=
argparse
.
FileType
(
"
r
"
),
help
=
"
MicroPython file to execute without writing to storage
"
)
parser
.
add_argument
(
"
-u
"
,
"
--upload
"
,
required
=
False
,
type
=
argparse
.
FileType
(
"
r
"
),
help
=
"
Tarball to unpack and upload into apps folder
"
,
)
parser
.
add_argument
(
"
-d
"
,
"
--device
"
,
default
=
"
/dev/ttyACM0
"
,
help
=
"
Serial device of the pycardium console
"
,
)
def
applyBase64
(
s
,
code
,
fun
=
"
exec
"
,
extraSetup
=
""
,
extraNewline
=
False
):
n
=
80
codechunks
=
[
code
[
i
:
i
+
n
]
for
i
in
range
(
0
,
len
(
code
),
n
)]
s
.
write
(
b
"
\x03
"
)
# ctrl-c
s
.
readline
()
s
.
write
(
b
"
import ubinascii;
\r\n
"
)
s
.
readline
()
s
.
write
(
b
"
code=[
\r\n
"
)
s
.
readline
()
for
chunk
in
codechunks
:
s
.
write
(
b
"'"
+
chunk
+
b
"'
,
\r\n
"
)
s
.
readline
()
#dont echo this line
s
.
write
(
b
"''
]
\r\n
"
)
s
.
readline
()
#print(s.readline())
for
cmd
in
extraSetup
:
if
len
(
cmd
)
>
0
:
s
.
write
(
bytes
(
cmd
,
'
utf-8
'
))
s
.
write
(
b
"
\r\n
"
)
s
.
readline
()
else
:
s
.
write
(
b
"
\r\n
"
)
s
.
readline
()
s
.
write
(
bytes
(
fun
,
'
utf-8
'
))
s
.
write
(
b
"
(ubinascii.a2b_base64(
''
.join(code)))
\r\n
"
)
if
extraNewline
:
s
.
write
(
b
"
\r\n
"
)
s
.
readline
()
s
.
readline
()
s
.
readline
()
args
=
parser
.
parse_args
()
if
args
.
run
is
None
and
args
.
upload
is
None
:
print
(
"
Either -e or -u has to be specified
"
)
with
serial
.
Serial
(
port
=
args
.
device
,
baudrate
=
115200
)
as
s
:
if
args
.
upload
is
not
None
:
tar
=
tarfile
.
TarFile
.
gzopen
(
args
.
upload
.
name
)
for
tarinfo
in
tar
:
print
(
tarinfo
.
name
)
payload
=
base64
.
b64encode
(
tar
.
extractfile
(
tarinfo
.
name
).
read
())
applyBase64
(
s
,
payload
,
fun
=
"
with open(
'
/apps/{}
'
,
\"
w
\"
) as f: f.write
"
.
format
(
tarinfo
.
name
),
extraSetup
=
[
"
try: os.mkdir(
\"
/apps/{}
\"
)
"
.
format
(
os
.
path
.
dirname
(
tarinfo
.
name
)),
"
except: pass
"
,
""
],
extraNewline
=
True
)
elif
args
.
run
is
not
None
:
payload
=
base64
.
b64encode
(
bytes
(
args
.
run
.
read
(),
"
utf-8
"
))
applyBase64
(
s
,
payload
)
try
:
buf
=
b
""
while
True
:
buf
+=
s
.
read
()
try
:
char
=
buf
.
decode
(
"
utf-8
"
)
print
(
char
,
end
=
""
)
buf
=
b
""
except
UnicodeDecodeError
as
e
:
if
len
(
buf
)
>
3
:
print
(
e
)
buf
=
b
""
except
KeyboardInterrupt
:
print
(
'
CTRL-C detected. Exiting gracefully.
'
)
s
.
write
(
b
"
\x03
"
)
This diff is collapsed.
Click to expand it.