Commit 347b7107 authored by Pedro Henrique Kopper's avatar Pedro Henrique Kopper

Update to new ping-pong req format

parent 5c0f2351
[submodule "Protocol"]
path = Protocol
url = git@git.cta.if.ufrgs.br:SADAPMAP/Protocol.git
......@@ -11,4 +11,4 @@ numpy = "*"
pyserial = "*"
pyqt5 = "*"
pyyaml = "*"
protobuf = "*"
Subproject commit 6a829cc7c094d271a50cffb86107d5b54af9df67
......@@ -19,7 +19,7 @@ class Arduino(object):
logger("[ARDUINO]", "Board started, good luck!")
def read(self):
return 10
pass
def readAll(self):
self.ser.flushInput() # Limpeza do buffer de entrada
......
This diff is collapsed.
This diff is collapsed.
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: Protocol/sadapmap.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
import nanopb_pb2.nanopb_pb2 as nanopb__pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name='Protocol/sadapmap.proto',
package='sadapmap',
syntax='proto2',
serialized_pb=_b('\n\x17Protocol/sadapmap.proto\x12\x08sadapmap\x1a\x0cnanopb.proto\"+\n\x0e\x43hannelReading\x12\n\n\x02id\x18\x01 \x02(\r\x12\r\n\x05value\x18\x02 \x02(\x02\"H\n\x13MultiChannelReading\x12\x31\n\x08\x63hannels\x18\x01 \x03(\x0b\x32\x18.sadapmap.ChannelReadingB\x05\x92?\x02\x10\x10\"i\n\x0f\x43hannelMetadata\x12\n\n\x02id\x18\x01 \x02(\r\x12\x13\n\x04name\x18\x02 \x02(\tB\x05\x92?\x02\x10 \x12\x13\n\x04unit\x18\x03 \x02(\tB\x05\x92?\x02\x10\x08\x12\x0f\n\x07minimum\x18\x04 \x02(\x02\x12\x0f\n\x07maximum\x18\x05 \x02(\x02\"\x1f\n\x11ReqChannelReading\x12\n\n\x02id\x18\x01 \x02(\r\"+\n\x16ReqMultiChannelReading\x12\x11\n\x02id\x18\x01 \x03(\rB\x05\x92?\x02\x10\x10')
,
dependencies=[nanopb__pb2.DESCRIPTOR,])
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
_CHANNELREADING = _descriptor.Descriptor(
name='ChannelReading',
full_name='sadapmap.ChannelReading',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='id', full_name='sadapmap.ChannelReading.id', index=0,
number=1, type=13, cpp_type=3, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
_descriptor.FieldDescriptor(
name='value', full_name='sadapmap.ChannelReading.value', index=1,
number=2, type=2, cpp_type=6, label=2,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax='proto2',
extension_ranges=[],
oneofs=[
],
serialized_start=51,
serialized_end=94,
)
_MULTICHANNELREADING = _descriptor.Descriptor(
name='MultiChannelReading',
full_name='sadapmap.MultiChannelReading',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='channels', full_name='sadapmap.MultiChannelReading.channels', index=0,
number=1, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\222?\002\020\020'))),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax='proto2',
extension_ranges=[],
oneofs=[
],
serialized_start=96,
serialized_end=168,
)
_CHANNELMETADATA = _descriptor.Descriptor(
name='ChannelMetadata',
full_name='sadapmap.ChannelMetadata',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='id', full_name='sadapmap.ChannelMetadata.id', index=0,
number=1, type=13, cpp_type=3, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
_descriptor.FieldDescriptor(
name='name', full_name='sadapmap.ChannelMetadata.name', index=1,
number=2, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\222?\002\020 '))),
_descriptor.FieldDescriptor(
name='unit', full_name='sadapmap.ChannelMetadata.unit', index=2,
number=3, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\222?\002\020\010'))),
_descriptor.FieldDescriptor(
name='minimum', full_name='sadapmap.ChannelMetadata.minimum', index=3,
number=4, type=2, cpp_type=6, label=2,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
_descriptor.FieldDescriptor(
name='maximum', full_name='sadapmap.ChannelMetadata.maximum', index=4,
number=5, type=2, cpp_type=6, label=2,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax='proto2',
extension_ranges=[],
oneofs=[
],
serialized_start=170,
serialized_end=275,
)
_REQCHANNELREADING = _descriptor.Descriptor(
name='ReqChannelReading',
full_name='sadapmap.ReqChannelReading',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='id', full_name='sadapmap.ReqChannelReading.id', index=0,
number=1, type=13, cpp_type=3, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax='proto2',
extension_ranges=[],
oneofs=[
],
serialized_start=277,
serialized_end=308,
)
_REQMULTICHANNELREADING = _descriptor.Descriptor(
name='ReqMultiChannelReading',
full_name='sadapmap.ReqMultiChannelReading',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='id', full_name='sadapmap.ReqMultiChannelReading.id', index=0,
number=1, type=13, cpp_type=3, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\222?\002\020\020'))),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax='proto2',
extension_ranges=[],
oneofs=[
],
serialized_start=310,
serialized_end=353,
)
_MULTICHANNELREADING.fields_by_name['channels'].message_type = _CHANNELREADING
DESCRIPTOR.message_types_by_name['ChannelReading'] = _CHANNELREADING
DESCRIPTOR.message_types_by_name['MultiChannelReading'] = _MULTICHANNELREADING
DESCRIPTOR.message_types_by_name['ChannelMetadata'] = _CHANNELMETADATA
DESCRIPTOR.message_types_by_name['ReqChannelReading'] = _REQCHANNELREADING
DESCRIPTOR.message_types_by_name['ReqMultiChannelReading'] = _REQMULTICHANNELREADING
ChannelReading = _reflection.GeneratedProtocolMessageType('ChannelReading', (_message.Message,), dict(
DESCRIPTOR = _CHANNELREADING,
__module__ = 'Protocol.sadapmap_pb2'
# @@protoc_insertion_point(class_scope:sadapmap.ChannelReading)
))
_sym_db.RegisterMessage(ChannelReading)
MultiChannelReading = _reflection.GeneratedProtocolMessageType('MultiChannelReading', (_message.Message,), dict(
DESCRIPTOR = _MULTICHANNELREADING,
__module__ = 'Protocol.sadapmap_pb2'
# @@protoc_insertion_point(class_scope:sadapmap.MultiChannelReading)
))
_sym_db.RegisterMessage(MultiChannelReading)
ChannelMetadata = _reflection.GeneratedProtocolMessageType('ChannelMetadata', (_message.Message,), dict(
DESCRIPTOR = _CHANNELMETADATA,
__module__ = 'Protocol.sadapmap_pb2'
# @@protoc_insertion_point(class_scope:sadapmap.ChannelMetadata)
))
_sym_db.RegisterMessage(ChannelMetadata)
ReqChannelReading = _reflection.GeneratedProtocolMessageType('ReqChannelReading', (_message.Message,), dict(
DESCRIPTOR = _REQCHANNELREADING,
__module__ = 'Protocol.sadapmap_pb2'
# @@protoc_insertion_point(class_scope:sadapmap.ReqChannelReading)
))
_sym_db.RegisterMessage(ReqChannelReading)
ReqMultiChannelReading = _reflection.GeneratedProtocolMessageType('ReqMultiChannelReading', (_message.Message,), dict(
DESCRIPTOR = _REQMULTICHANNELREADING,
__module__ = 'Protocol.sadapmap_pb2'
# @@protoc_insertion_point(class_scope:sadapmap.ReqMultiChannelReading)
))
_sym_db.RegisterMessage(ReqMultiChannelReading)
_MULTICHANNELREADING.fields_by_name['channels'].has_options = True
_MULTICHANNELREADING.fields_by_name['channels']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\222?\002\020\020'))
_CHANNELMETADATA.fields_by_name['name'].has_options = True
_CHANNELMETADATA.fields_by_name['name']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\222?\002\020 '))
_CHANNELMETADATA.fields_by_name['unit'].has_options = True
_CHANNELMETADATA.fields_by_name['unit']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\222?\002\020\010'))
_REQMULTICHANNELREADING.fields_by_name['id'].has_options = True
_REQMULTICHANNELREADING.fields_by_name['id']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\222?\002\020\020'))
# @@protoc_insertion_point(module_scope)
......@@ -6,4 +6,4 @@ from interfaces.Arduino import *
INTERFACES = {
'mock': Mock,
'arduino': Arduino
}
\ No newline at end of file
}
This diff is collapsed.
from time import sleep
import serial
from interfaces.Protocol.sadapmap_pb2 import MultiChannelReading, ReqMultiChannelReading
with serial.Serial("/dev/ttyUSB0", 115200, timeout=0.1) as ser:
print("Opened serial")
while True:
req = ReqMultiChannelReading()
req.id.append(0)
ser.flushInput()
ser.write(req.SerializeToString())
reading = MultiChannelReading()
data = ser.read(128)
print(data)
try:
reading.ParseFromString(data)
except:
print("FAILLLLLLLLLLLLLLLLLLLLLLLLL")
print(reading)
sleep(0.1)
\ No newline at end of file
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