Merge lp://staging/~hesky-fisher/plover/txbolt into lp://staging/plover

Proposed by Hesky Fisher
Status: Merged
Merged at revision: 44
Proposed branch: lp://staging/~hesky-fisher/plover/txbolt
Merge into: lp://staging/plover
Diff against target: 96 lines (+80/-2)
2 files modified
plover/machine/__init__.py (+4/-2)
plover/machine/txbolt.py (+76/-0)
To merge this branch: bzr merge lp://staging/~hesky-fisher/plover/txbolt
Reviewer Review Type Date Requested Status
Joshua Harlan Lifton Approve
Review via email: mp+80724@code.staging.launchpad.net

Description of the change

Adds support for TX Bolt protocol. I've tested this with a stentura protege.

To post a comment you must log in.
Revision history for this message
Joshua Harlan Lifton (joshua-harlan-lifton) wrote :

Thanks, Hesky. I should be able to get to this before the end of the weekend.

Revision history for this message
Joshua Harlan Lifton (joshua-harlan-lifton) wrote :

Sorry this is coming a day later than I would have liked. Regarding your code comment about serial data capture depending on timing, I think you can safely discard lines 77-83 and replace line 86 with

raw = self.serial_port.read(BYTES_PER_STROKE)

where BYTES_PER_STROKE = 4 is listed at the top of the module. Lines 92-94 would then be changed to check that exactly four bytes were received. Basically, I think you can mirror main loop of geminipr.py, even with the occasional 0 byte thrown in, though best to explicitly check that it is what you think it is before discarding it.

The reason this will work is that the default serial timeout for Plover is 2 seconds, which means that if you read the serial port in the middle of receiving a four-byte packet, it will return the full four bytes to you so long as there's no more than 2 seconds between each byte. I think what you have now should also work for the same reason, but I think it could be paired down a bit and made slightly more transparent.

Would you mind testing these changes? I'm happy to help over IRC or e-mail or phone.

review: Needs Fixing
Revision history for this message
Hesky Fisher (hesky-fisher) wrote :

Hi Josh,

I did notice that TX Bolt and Gemini have a lot in common but unfortunately
they are not the same. TX Bolt doesn't write four byte packets like the
Gemini. Instead, it only writes those bytes for which keys have been
pressed. So any stroke can be one, two, three or four bytes long. That is
why the code is a bit complicated. The only way to tell that a stroke has
ended is by seeing a byte for an earlier set of keys, a zero byte, or, and
this is where I am not completely sure, by seeing that the buffer is empty.

Hesky

On Mon, Oct 31, 2011 at 11:40 PM, Joshua Harlan Lifton <
<email address hidden>> wrote:

> Review: Needs Fixing
>
> Sorry this is coming a day later than I would have liked. Regarding your
> code comment about serial data capture depending on timing, I think you can
> safely discard lines 77-83 and replace line 86 with
>
> raw = self.serial_port.read(BYTES_PER_STROKE)
>
> where BYTES_PER_STROKE = 4 is listed at the top of the module. Lines 92-94
> would then be changed to check that exactly four bytes were received.
> Basically, I think you can mirror main loop of geminipr.py, even with the
> occasional 0 byte thrown in, though best to explicitly check that it is
> what you think it is before discarding it.
>
> The reason this will work is that the default serial timeout for Plover is
> 2 seconds, which means that if you read the serial port in the middle of
> receiving a four-byte packet, it will return the full four bytes to you so
> long as there's no more than 2 seconds between each byte. I think what you
> have now should also work for the same reason, but I think it could be
> paired down a bit and made slightly more transparent.
>
> Would you mind testing these changes? I'm happy to help over IRC or e-mail
> or phone.
>
> --
> https://code.launchpad.net/~hesky-fisher/plover/txbolt/+merge/80724
> You are the owner of lp:~hesky-fisher/plover/txbolt.
>

Revision history for this message
Hesky Fisher (hesky-fisher) wrote :

In retrospect, my comments comparing Gemini and Bolt weren't accurate. My point was just that the packet sizes aren't fixed.

Revision history for this message
Joshua Harlan Lifton (joshua-harlan-lifton) wrote :

Ah, I didn't realize the Bolt uses variable length packets. In that case, please call this out explicitly in the comments at the top of the file. Also, I still think you can get rid of lines 77-83 because lines 92-94 will do the same thing since when no bytes are in waiting self.serial_port.read(self.serial_port.inWaiting()) will evaluate to either '' or [], depending on the version of Python.

46. By Hesky Fisher

- Updated comment to explain that txbolt uses variable length packets.
- Removed unnecessary code.

Revision history for this message
Hesky Fisher (hesky-fisher) wrote :

Done. Please take another look.

Revision history for this message
Joshua Harlan Lifton (joshua-harlan-lifton) wrote :

Looks good! I'll merge this in shortly.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches