Skip to content

does this work? #14

@ohsix

Description

@ohsix

$ cat /tmp/f.py

#!/usr/bin/env python3
from oatmeal import OatmealDevice
import logging

logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                    level=logging.NOTSET)

class MyDevice(OatmealDevice):
    ROLE_STR = "MyDevice"

board = MyDevice.find()
print("Temperature: ", board.send_and_ack("TMPR").args[0])

cat f.ino

#define HARDWARE_ID_STR "MyDevice"
#include "oatmeal_protocol.h"

OatmealPort port = OatmealPort(&Serial, "MyDevice");

void setup() {
  port.init();
}

void loop() {
  OatmealMsg msg;
  while (port.check_for_msgs(&msg)) {
    if (msg.is_opcode("TMPR")) {
      port.start("TMP", 'A', port.next_token());
      port.append(32);
      port.append(48);
      port.finish();
    }
  }
}

this is on linux. initially I thought it was the timeout for ask_who, then I changed that directly and it still didn't work

in the udp monitor (with the changed timeout) there are messages going back and forth

<DISRdM>iS
<DISRdN>iV
<HRTRdAT>pb
<HRTRdBT>p?
<HRTRdCT>pd
<HRTRdDT>pA
<DISAdN"MyDevice",0,"\"UNDEF_ID\"","\"UNDEF_VER\"">$~

the log from running f.py

2021-01-10 22:01:51,371 DEBUG: Trying to connect to /dev/ttyUSB0...
2021-01-10 22:01:51,373 INFO: Starting reading/writing UART.
2021-01-10 22:01:51,374 DEBUG: Querying device...
2021-01-10 22:01:56,381 DEBUG: Missed ack: OatmealMsg('DISR', token='dM')
2021-01-10 22:01:56,393 INFO: Stopped reading/writing UART.
2021-01-10 22:01:56,393 INFO: Approximate UART received stats...
2021-01-10 22:01:56,393 INFO:   # frame too long: 0
2021-01-10 22:01:56,394 INFO:   # frame too short: 0
2021-01-10 22:01:56,394 INFO:   # missing start byte: 0
2021-01-10 22:01:56,394 INFO:   # missing end byte: 0
2021-01-10 22:01:56,394 INFO:   # non-ascii bytes: 0
2021-01-10 22:01:56,394 INFO:   # bad checksum: 0
2021-01-10 22:01:56,394 INFO:   # misc bad frames: 0
2021-01-10 22:01:56,394 INFO:   # good frames: 1
2021-01-10 22:01:56,401 INFO: Starting reading/writing UART.
2021-01-10 22:01:56,903 DEBUG: Missed ack: OatmealMsg('HRTR', True, token='dA')
2021-01-10 22:01:57,405 DEBUG: Missed ack: OatmealMsg('HRTR', True, token='dB')
2021-01-10 22:01:57,907 DEBUG: Missed ack: OatmealMsg('HRTR', True, token='dC')
2021-01-10 22:01:58,409 DEBUG: Missed ack: OatmealMsg('HRTR', True, token='dD')
Traceback (most recent call last):
  File "/tmp/f.py", line 11, in <module>
    board = MyDevice.find()
  File "/home/ohsix/.local/lib/python3.8/site-packages/oatmeal/device.py", line 204, in find
    role_device.toggle_heartbeats(True)
  File "/home/ohsix/.local/lib/python3.8/site-packages/oatmeal/device.py", line 159, in toggle_heartbeats
    self.port.send_and_ack(command, "HRTA")
  File "/home/ohsix/.local/lib/python3.8/site-packages/oatmeal/protocol.py", line 1427, in send_and_ack
    raise OatmealTimeout("No ACK! (%s retries, %s timeout)" % (
oatmeal.protocol.OatmealTimeout: No ACK! (3 retries, 0.5 timeout)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions