evil-mad / EggBot

Software for The Original EggBot
GNU General Public License v3.0
287 stars 140 forks source link

Add general status query function #111

Closed oskay closed 5 years ago

oskay commented 5 years ago

Suggestion: Add a single query function that handles the most common status request items -- to help with handling high-performance use of the EBB.

Where:

or possibly (and probably better)

EmbeddedMan commented 5 years ago

Heck yeah. This makes a ton of sense and should be very simple to implement.

On Mon, Jan 7, 2019 at 1:19 PM Windell Oskay notifications@github.com wrote:

Suggestion: Add a single query function that handles the most common status request items -- to help with handling high-performance use of the EBB.

  • Format: QG
  • Response: button,pen,motor1,motor2,fifo

Where:

  • button gives the button status (equivalent to calling QB)
  • pen gives the pen status (equivalent to calling QP)
  • motor1, motor2, and fifo give the motor status (moving or not) and FIFO status (equivalent to calling QM).

or possibly (and probably better)

  • Response: status_byte Giving a single byte: xxxABCDE:

  • x: Reserved

  • A: button

  • B: pen

  • C: motor1

  • D: motor2

  • E: fifo

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/111, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCHCLlUEpAPk1eqvVLvxyB1tyIvaqks5vA53KgaJpZM4Z0F9S .

EmbeddedMan commented 5 years ago

What would make for the easiest output (for both humans and machines) - a single hexadecimal byte, a single byte as an integer (zero padded?) or eight "0"s / "1"s representing the eight bits of the byte?

oskay commented 5 years ago

Probably a single hex byte, so as to minimize the total number of characters being sent.

EmbeddedMan commented 5 years ago

New version 2.6.1 is now waiting for your testing and review in Branch_Issue111. Docs updated as well.

oskay commented 5 years ago

Is there a reason to have the OK on the end there?

EmbeddedMan commented 5 years ago

No, other than it's there on all of the other commands. You can turn off all "OK" responses to speed things up if you want.

On Wed, Jan 9, 2019 at 3:20 PM Windell Oskay notifications@github.com wrote:

Is there a reason to have the OK on the end there?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/111#issuecomment-452845666, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCK66xF0JxEXnCqbUiYVzHGxtp_kkks5vBl05gaJpZM4Z0F9S .

oskay commented 5 years ago

It's there on many of the other commands. This was modeled on QM, which doesn't. I could go either way on it.

One additional thing: I think that we should add the CommandStatus bit to this as well. Then it's a weighty and efficient status byte. (Are there others that should be added?)

If there should ever be an opportunity to rewrite the interface, it might be good to replace the QB, QP, and QM queries with just this one.

EmbeddedMan commented 5 years ago

Sure. All good points. There isn't a practical use for the "OK" at the end since this command has a nice fixed output format that you can parse on the PC side. I'll remove it.

I like adding the CommandStatus in as well. I can't think of any other status bits that would be useful right now, but what about throwing the digital logic state of 2 of the PortB 3-pin connectors in there? (So they could be used for easy limit switches.)

On Wed, Jan 9, 2019 at 3:53 PM Windell Oskay notifications@github.com wrote:

It's there on many of the other commands. This was modeled on QM, which doesn't. I could go either way on it.

One additional thing: I think that we should add the CommandStatus bit to this as well. Then it's a full and efficient status byte. (Are there others that should be added?)

If there should ever be an opportunity to rewrite the interface, it might be good to replace the QB, QP, and QM queries with just this one.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/111#issuecomment-452882480, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCGIR3R10YQu6zPKM9K7yRbzVVbzJks5vBmTSgaJpZM4Z0F9S .

oskay commented 5 years ago

Sure. That sounds good.

EmbeddedMan commented 5 years ago

OK, branch has been updated with the proposed changed.

EmbeddedMan commented 5 years ago

Oskay, have you had a chance to test out these changes? It would be great to get PR #112 merged in if the new command works for you.

oskay commented 5 years ago

I think that this command is not quite working correctly, as of 2.6.1 -- or at least, does not match the documentation.

With no commands but pen down, QG gives 00 -- OK.

Pressing the button, QG now gives 10 (decimal 16, 0001 0000 binary), suggesting that bit 4 (not 5) is giving the button status.

Moving with the pen down and one item in the FIFO gives 07, or 0000 0111 binary, suggesting that bit 3 ("CommandStaus" <- noting typo) is not working as expected.

Toggling the pen up and again moving with an item in the FIFO gives 0F, decimal 15, or 0000 1111 binary, suggesting that bit 3 (not 4) is the pen position.

I have not tested the GPIO indicator bits.

We should also add an HTML table showing the bit positions (like a register description from MCU docs), to make it clear which is the low and high bit, and also give the "decimal value per bit" which can make it a little easier to follow.

EmbeddedMan commented 5 years ago

Thanks for testing this. I'll figure out what's going on and update the code/docs.

EmbeddedMan commented 5 years ago

I think part of the problem here is the documentation - mainly the numbering of the bits. I think we should number them bits 1 through 8.

So testing the existing code, I get the following results. (Note: all of these tests had jumpers from RB2 and RB5 to GND):

So I think it is all working as expected, as far as I can tell. I have updated the documentation with this bit numbering change, as well as the table you suggested, and added more bit description text, but no code changes are necessary.

oskay commented 5 years ago

Ha! You changed the behavior of QG between the two versions!

From the Issue 111 (this issue) branch, using v 2.6.1 (as I reported), after reset, we get: QG: 08 (0000 1000)

After toggling the pen, we get QG: 00 (0000 0000)

So bit 3, starting the numbering at bit 0 following datasheet conventions (such that we're talking about the bit that represents 2^3 = 8) gives the pen status -- just as I had reported.

From the Issue 113 branch, using v 2.6.2, after reset, we get: QG: D0 (1101 0000)

After toggling the pen, we get QG: C0 (1100 0000)

So, in 2.6.2, bit 4 (2^4 = 16) gives the pen status. That's quite different.

I'll try and test the rest of the functions, if we're targeting 2.6.2

EmbeddedMan commented 5 years ago

I think I forgot to check in the hex file somewhere. Hold on a bit and I'll get it sorted out.

On Fri, Mar 15, 2019, 11:27 AM Windell Oskay notifications@github.com wrote:

Ha! You changed the behavior of QG between the two versions!

From the Issue 111 (this issue) branch, using v 2.6.1 (as I reported), after reset, we get: QG: 08 (0000 1000)

After toggling the pen, we get QG: 00 (0000 0000)

So bit 3, starting the numbering at bit 0 following datasheet conventions (such that we're talking about the bit that represents 2^3 = 8) gives the pen status -- just as I had reported.

From the Issue 113 branch, using v 2.6.2, after reset, we get: QG: D0 (1101 0000)

After toggling the pen, we get QG: C0 (1100 0000)

So, in 2.6.2, bit 4 (2^4 = 16) gives the pen status. That's quite different.

I'll try and test the rest of the functions, if we're targeting 2.6.2

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/111#issuecomment-473353370, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCGLdCazq7yhYBTGZn_-1fw1mU5dFks5vW8n6gaJpZM4Z0F9S .

oskay commented 5 years ago

On 2.6.2:

Bit 0: 0x01 (0000 0001): FIFO full

Bit 1: 0x02 (0000 0010): Motor 2

Bit 2: 0x04 (0000 0100): Motor 1

Bit 3: 0x08 (0000 1000): Motion Command

Bit 4: 0x10 (0001 0000): Pen Up

Bit 5: 0x20 (0010 0000): PRG Button

Bit 6: 0x40 (0100 0000): B2 status: High for on

Bit 7: 0x80 (1000 0000): B5 status: High for on

EmbeddedMan commented 5 years ago

Yes, you are quite right. The v2.6.1 does not have the latest version of the QG command - the v2.6.2 code does. My mistake - I got confused with the branches. If we merge this branch (Branch_Issue111) in first (to get the doc changes), then merge in Branch_Issue113 we'll get the right documentation changes and the right code changes for both HM and QG.

So, considering the QG doc changes in this branch, coupled with the v2.6.2 hex file, are there still issues to resolve, or do you think we're good to merge?

oskay commented 5 years ago

OK; I'll go ahead and merge 111, then 113, with your approval.

I do want to make some changes to the QG docs, but I can do that after the merges.

EmbeddedMan commented 5 years ago

Perfect? Thanks

On Fri, Mar 15, 2019, 6:40 PM Windell Oskay notifications@github.com wrote:

OK; I'll go ahead and merge 111, then 113, with your approval.

I do want to make some changes to the QG docs, but I can do that after the merges.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/111#issuecomment-473473717, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCKOlAwKFwdMDUceKnQx6MdrkLeZNks5vXC-AgaJpZM4Z0F9S .

oskay commented 5 years ago

OK, merged!

oskay commented 5 years ago

I've made some significant changes to the docs of this and a few other commands -- please check the diffs.

EmbeddedMan commented 5 years ago

I have to say - nothing but improvements. :-)

oskay commented 5 years ago

It looks like the 2.6.2 firmware updater is not published yet -- is that correct?

EmbeddedMan commented 5 years ago

Well, would you look at that. It certainly is not there yet. I'll get right on it.

*Brian

On Thu, Apr 18, 2019 at 1:03 PM Windell Oskay notifications@github.com wrote:

It looks like the 2.6.2 firmware updater is not published yet -- is that correct?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/111#issuecomment-484618823, or mute the thread https://github.com/notifications/unsubscribe-auth/AADN4CFQOC2BKQGAEFV3RCTPRCZWRANCNFSM4GOQL5JA .

EmbeddedMan commented 5 years ago

OK, the 2.6.2 updater is now in the repo.

oskay commented 5 years ago

Great-- thanks!

oskay commented 5 years ago

I'm updating the Mac installer as well, posting direct links in the AxiDraw releases page, and will update the EBB docs page to directly link to our wiki page about updating firmware.