evil-mad / EggBot

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

(EBB) Add ability to give an EBB a 'name' #83

Closed EmbeddedMan closed 6 years ago

EmbeddedMan commented 7 years ago

It would be really slick if, on a given computer, you could have multiple EggBots, AxiDraws and WaterColorBots all plotting away from separate instances of Inkscape at the same time.

To support this, some way of choosing which EBB a given Inkscape connects to is needed. I have no idea how to do this in Inkscape, or if it's even possible. But no matter what, EBB will need a unique identifier.

So, this feature request is to add a new set of commands. One for writing down a new 'name', and one for reading back that name. This name string will of course need to be stored in Flash, as these parts have no true EEPROM, but that's not a big deal. (I think)

Many bonus points if this name also shows up in the device manager. :-)

oskay commented 6 years ago

I'd like to get this wrapped up soon if we can; AxiDraw multi-machine support is almost ready and this would help. So far as I can tell, this feature is working and usable.

We should likely add a note in the docs discouraging programmatic setting of the name tag (flash lifetime yada yada). Also, it might be good to use some example without an apostrophe, since those don't translate as well in the com port listings.

EmbeddedMan commented 6 years ago

So, you say the feature is working and usable - but we haven't added an EBB firmware command to support the naming yet, have we? I don't see it in the release notes. Can you clarify what's left to be done?

oskay commented 6 years ago

Look at the changes in the EBB_naming branch that you created?

EmbeddedMan commented 6 years ago

I think I'd forget the names of my kids if they didn't remind me. So, if the only thing to do just merge the branch and build a new version?

On Tue, May 8, 2018, 9:18 PM Windell Oskay notifications@github.com wrote:

Look at the changes in the EBB_naming branch that you created?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/83#issuecomment-387599527, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCNy5G--DpvwRftcCSn7rjYcCmoIDks5twlH3gaJpZM4O1aqe .

oskay commented 6 years ago

I think that the firmware is built (but please double check)-- we'd need to merge, make those little updates to the docs, and build the windows updater program. I've already built a Mac updater for 2.5.4 -- please let me know if there is any reason not to make EBF_v254.unified.hex the new version.

(Also on the topic of updater programs: please update your the "Updating Your Firmware" section on your main EBB page, with a link to the much-easier-for-most-people version at: https://wiki.evilmadscientist.com/Updating_EBB_firmware )

EmbeddedMan commented 6 years ago

Ahh! Yes, that's a very good idea. Will do.

On Tue, May 8, 2018 at 9:56 PM, Windell Oskay notifications@github.com wrote:

I think that the firmware is built (but please double check)-- we'd need to merge, make those little updates to the docs, and build the windows updater program. I've already built a Mac updater for 2.5.4 -- please let me know if there is any reason not to make EBF_v254.unified.hex the new version.

(Also on the topic of updater programs: please update your the "Updating Your Firmware" section on your main EBB page, with a link to the much-easier-for-most-people version at: https://wiki.evilmadscientist. com/Updating_EBB_firmware )

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

EmbeddedMan commented 6 years ago

The branch has been merged. The windows updater has been updated. The SchmalzHaus EBB documentation page has been updated. I see no reason why 2.5.4 should not be the new version.

oskay commented 6 years ago

Fantastic. Thank you!

oskay commented 6 years ago

I'm not seeing the Windows app. I'd expect it to be called EBBUpgraderGUI_v254.exe?

EmbeddedMan commented 6 years ago

Sorry - forgot to include the executable. It should be there now. And yes, you got the name right.

oskay commented 6 years ago

Great; thank you again.

oskay commented 6 years ago

I've been trying to connect the dots on this, but haven't quite succeeded in making things work right on Windows.

With 2.5.4, I can write and read the device name successfully (Mac & Win), using the EBB commands. However, I'm not having the same luck with the USB descriptions.

Listing the port information via pyserial on Mac, I get the following: port[0]: /dev/cu.usbmodem1441 port[1]: EiBotBoard_East port[2]: USB VID:PID=04D8:FD92 LOCATION=20-4

This is correct as far as I can tell, and lets me successfully open a serial connection to that EBB alone.

Trying the same thing on Windows 10, I get the following:

port[0]: COM6 port[1]: USB Serial (UBW-based) communications port (COM6) port[2]: USB VID:PID=04D8:FD92 SNR=5

Further, I don't see any mention of the name ("East") in the device manager. It seems like this is not quite working right. My impression is that it is currently not possible to determine a machine's name tag on windows without opening full serial communication to it.

EmbeddedMan commented 6 years ago

It appears each os does this stuff a little differently. Actually, from what I can tell, all other OSes do it one way, and Windows does it a different way.

If you set the name of your EBB to "Brian123" for example, and you want to see this show up in the Device Manager, you need to right click on the COM port in DM, select Properties, go to the Details tab and pull down the "Bus reported device description" property. Then you'll see "EiBotBoard,Brian123".

It's definitely there under Windows 10. The tough part is figuring out how to access it from a given language.

What gets shown on the actual Device Manager window as the name of the COM port is called the "Display Name" and it's set via the INF file, not via device descriptors in the device itself as far as I can tell. (There may be magic here that I just don't understand that would allow us to get a unique name in the Display Name field.)

I don't know any python, or how easy it is to access Windows C calls from within it, but this page does give some code snippets that look like they may provide this Bus reported device description value that we're looking for:

https://social.msdn.microsoft.com/Forums/lync/en-US/35ad96d5-df46-469d-be06-5ab78f090b31/how-to-get-the-bus-reported-device-description-of-a-device?forum=csharpgeneral

I really wish this were consistently implemented across OSes but as far as I can tell it isn't.

EmbeddedMan commented 6 years ago

In addition, the standard tool for Windows to see what a USB device makes available to the OS is USBView (which can be downloaded from here : http://www.ftdichip.com/Support/Utilities.htm#MicrosoftUSBView)

The device descriptor for an EBB will list the full name "EiBotBoard,Brian123" as a string descriptor under the iProduct field in that tool.

EmbeddedMan commented 6 years ago

After more research, it looks like WMI does not give this information. Instead, one has to use this call: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/devpkey-device-busreporteddevicedesc from the Setup API in Windows to get it.

oskay commented 6 years ago

Interesting. I can indeed see it as "Bus reported device description" in the device manager. That's something to go on.

I also note that it lists "SNR=5" -- do you have access to update the serial number?

EmbeddedMan commented 6 years ago

YES! I think the serial number is one of the other things that's not hard to change on the fly. However, if you change the serial number, Windows will assign it whatever the next unused COM port number is. So if you change serial numbers a lot (to new unique values) you'l use up a lot of COM ports, which may be just fine.

On Fri, Jul 6, 2018 at 11:24 AM, Windell Oskay notifications@github.com wrote:

Interesting. I can indeed see it as "Bus reported device description" in the device manager. That's something to go on.

I also note that it lists "SNR=5" -- do you have access to update the serial number?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/83#issuecomment-403082149, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCPKcxDCqau_6WWV-CIvaVROOFHyKks5uD49JgaJpZM4O1aqe .

oskay commented 6 years ago

So... what if we make the name tag also show up as the SN?

EmbeddedMan commented 6 years ago

Right - I'll give that a go.

On Fri, Jul 6, 2018 at 12:10 PM, Windell Oskay notifications@github.com wrote:

So... what if we make the name tag also show up as the SN?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/83#issuecomment-403093933, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCGBtjFYI2ecm8Qw-GYnSurddrq1Pks5uD5oUgaJpZM4O1aqe .

oskay commented 6 years ago

I'll keep digging in the other direction as well. :)

EmbeddedMan commented 6 years ago

This tool https://www.uwe-sieber.de/usbtreeview_e.html#download is much better than the simple USB View. It shows way more information about exactly what the OS knows about a USB device.

Interestingly, I see that when an EBB is 'fresh' (i.e. just programmed, never been given a name before) USB Device Tree Viewer shows the "Product string" as "EiBotBoard,****" where the * are actually little circles. Like it's getting a string with the full 27 characters but the last 16 are invalid unicode or something? I'll need to look into that.

EmbeddedMan commented 6 years ago

OK, version 2.5.5 is ready for your testing. The 'name' written using the ST command will now be used for the USB Serial Number field, as well as appended to the end of the device name field.

I also fixed the bug that was adding extra characters at the end of the device name field.

Give it a good test to see if you're able to query the serial number somehow from python or not.

If it doesn't work, I think we should revert the change, because every time you change the serial number you will get a new com port. (I'm up to about COM48 on my PC because of all of the testing today.) That may not be desirable behavior if the serial number field doesn't buy us anything.

oskay commented 6 years ago

cool! Testing.

USB data on Mac: port[0]: /dev/cu.usbmodemNort1 port[1]: EiBotBoard_North port[2]: USB VID:PID=04D8:FD92 SER=North LOCATION=20-6

Interesting (1): The USB enumeration has changed. Interesting (2): It's now reporting the serial number in the port[2] field.

On Windows: port[0]: COM3 port[0]: USB Serial (UBW-based) communications port (COM3) port[0]: USB VID:PID=04D8:FD92 SER=NORTH LOCATION=1-9

So-- it's working. And, I'd say much better than it was before, since both platforms are on more equal footing. Looks like a winner.

I should be able to have a version of AxiDraw Control for you to try that can individually address different machines very soon, with this addition. Would you be interested to try it?

EmbeddedMan commented 6 years ago

I would love to check it out, but I'll be honest, I likely won't have time to actually set it up for a couple of weeks, so don't rush.

On Fri, Jul 6, 2018 at 5:22 PM, Windell Oskay notifications@github.com wrote:

cool! Testing.

USB data on Mac: port[0]: /dev/cu.usbmodemNort1 port[1]: EiBotBoard_North port[2]: USB VID:PID=04D8:FD92 SER=North LOCATION=20-6

Interesting (1): The USB enumeration has changed. Interesting (2): It's now reporting the serial number in the port[2] field.

On Windows: port[0]: COM3 port[0]: USB Serial (UBW-based) communications port (COM3) port[0]: USB VID:PID=04D8:FD92 SER=NORTH LOCATION=1-9

So-- it's working. And, I'd say much better than it was before, since both platforms are on more equal footing. Looks like a winner.

I should be able to have a version of AxiDraw Control for you to try that can individually address different machines very soon, with this addition. Would you be interested to try it?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/83#issuecomment-403160958, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCKdIQHBTf0uYCSCMlbtV1D9wUXqZks5uD-M1gaJpZM4O1aqe .

oskay commented 6 years ago

Would you have time to roll the Windows updater for 2.5.5?

EmbeddedMan commented 6 years ago

Yup, for sure

On Fri, Jul 6, 2018, 5:29 PM Windell Oskay notifications@github.com wrote:

Would you have time to roll the Windows updater for 2.5.5?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/83#issuecomment-403161935, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCK26qvs1KWDMNWLzLOXofb0P8Oihks5uD-TSgaJpZM4O1aqe .

EmbeddedMan commented 6 years ago

OK, should be good to go now. Try it out.

On Fri, Jul 6, 2018 at 5:46 PM, Brian Schmalz brian@schmalzhaus.com wrote:

Yup, for sure

On Fri, Jul 6, 2018, 5:29 PM Windell Oskay notifications@github.com wrote:

Would you have time to roll the Windows updater for 2.5.5?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/evil-mad/EggBot/issues/83#issuecomment-403161935, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCK26qvs1KWDMNWLzLOXofb0P8Oihks5uD-TSgaJpZM4O1aqe .

oskay commented 6 years ago

Not working, thus far. Fails with runtime error: Dimension 1 should be between 1 and 0. Current value 1.

EmbeddedMan commented 6 years ago

Hmm. I'm unable to reproduce that error. I just updated every EBB I own and they all went fine without any problems.

Does it give any more information about the runtime error? Can you take a screenshot of it?

On Sat, Jul 7, 2018 at 1:44 PM, Windell Oskay notifications@github.com wrote:

Not working, thus far. Fails with runtime error: Dimension 1 should be between 1 and 0. Current value 1.

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

oskay commented 6 years ago

Well... after getting that error several times, it appears to be working now. :( I guess we're good. :?