Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

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
Select Git revision
Show changes
Commits on Source (3)
...@@ -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 = ''
......
#!/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")