1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

Polished binding to protobuf, msg.

This commit is contained in:
slush0 2016-04-04 23:51:25 +02:00 committed by Pavol Rusnak
parent 456e1fba44
commit ee9b9ca351
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 25 additions and 10 deletions

3
emu.sh
View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
cd `dirname $0`/src cd `dirname $0`/src
../vendor/micropython/unix/micropython -i -O0 -X heapsize=100000 main.py rm -f ../pipe.*
../vendor/micropython/unix/micropython -O0 -X heapsize=100000 main.py

View File

@ -13,8 +13,8 @@ import gc
from uasyncio import core from uasyncio import core
# import transport_pipe as pipe # import transport_pipe as pipe
from trezor import ui, io from trezor import ui
from trezor import msg2 as msg from trezor import msg
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
loop = core.get_event_loop() loop = core.get_event_loop()

View File

@ -1,5 +0,0 @@
from TrezorMsg import Msg
from TrezorProtobuf import Protobuf
msg = Msg()
protobuf = Protobuf()

View File

@ -3,7 +3,7 @@ import sys
if sys.platform == 'linux': if sys.platform == 'linux':
import transport_pipe as pipe import transport_pipe as pipe
def write(msg): def send(msg):
return pipe.write(msg) return pipe.write(msg)
def read(): def read():
@ -15,4 +15,14 @@ if sys.platform == 'linux':
pipe.init('../pipe') pipe.init('../pipe')
else: else:
NotImplemented("HID transport") from TrezorMsg import Msg
def send(msg):
return Msg.send(msg)
def read():
raise NotImplemented
return Msg.receive()
def set_notify(_on_read):
raise NotImplemented

9
src/trezor/protobuf.py Normal file
View File

@ -0,0 +1,9 @@
from TrezorProtobuf import Protobuf
_protobuf = Protobuf()
def encode(data):
return _protobuf.encode(data)
def decode(data):
return _protobuf.decode(data)