I've started tinkering with a Create 2, but I'm having issues reliably getting it to accept my commands. I can occasionally get it right, but sometimes, it just seems to ignore me. I'm guessing my cleanup code isn't getting the state fully reset or something. Is there a good pattern to follow for fail-safe initialization code?
Here's what I'm doing right now:
- Pulse BRC low for 1 second
- Wait 1 second
- Send 16x 0 bytes (to make sure if it's waiting for the rest of a command, this completes it - seemed to help a bit when I added this)
- Send 7 (reset)
- Wait 10 seconds
- Send 128 (start)
- Wait 2 seconds
- Send 149 35 (ask for the current OI state)
- Wait 1 second
- Send 131 (safe mode)
Sometimes I'm then able to issue 137 (drive) commands and have it work. Most times it doesn't. The times when it doesn't, I'm seeing a lot of data coming from the Create 2 that I'm not expecting, that looks something like this (hex bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3f 2a ff 73 21 09 cc 0a 88 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3f 2a ff 73 21 09 cc 0a
There's more, but my logging cut it off. I get the same pattern a couple of times, and it seems to be at least partially repeating. I thought maybe it's the 16 0-bytes I sent followed by 003f 2aff 7321 09cc 0a88
, but I still don't know how to interpret that.
Sometimes it will make some noise for the reset command, but usually ignores the start/safe mode commands completely (I can tell because the green light stays on).