PyBytes API Documentation



  • Is it just me or is the documentation for the PyBytes API HORRIBLY inadequate? We are trying to build a commercial product with GPy and I am almost regretting my decision.

    Sometimes in your program, when the Pybytes connection is disconnected and you apply a pyBytes method to attempt to reconnect, you get NameErrror: name 'pybytes' isn't defined. WTF does this even mean? Pybytes was there just a second ago!

    this method is pulled DIRECTLY from the documentation:

    pybytes.connect_LTE(reconnect=True, check_interval=0.5)

    When run it gives us : "TypeError: unexppected keyword argument 'reconnect'

    REALLY?

    That leads me to the documentation of course....

    Send information message
    
    Send information message.
    Method
    
    pybytes.send_info_message()
    Example
    
    pybytes.send_info_message()
    
    Send ping message
    
    Send ping message.
    Method
    
    pybytes.send_ping_message()
    Example
    
    pybytes.send_ping_message()
    

    again, REALLY? Would it hurt you to tell us how to program the function and supply an example or two? I had FAR BETTER documentation with my TRS-80 Model 1 computer in 1977!

    I am trying to count on this device for a commercial project that could easily be 1,000 units, but its getting harder to justify every day.


  • Global Moderator

    Right, that means the pybytes library is not loaded on boot (do you perhaps have pycom.pybytes_on_boot() set to False? )

    You can load the Pybytes library yourself by using:

    from _pybytes import Pybytes
    from _pybytes_config import PybytesConfig
    conf = PybytesConfig().read_config()
    pybytes = Pybytes(conf)
    pybytes.start()
    

    Gijs



  • @Gijs Fails means the pybytes.reconnect() returns this error NameErrror: name 'pybytes' isn't defined.


  • Global Moderator

    Could you elaborate on what 'fails' means exactly?
    All the pybytes.reconnect() does, is issue a disconnect() command, followed by a connect() command

    From the source:

    def reconnect(self):
            self.__check_init()
            try:
                self.disconnect()
                time.sleep(1)
                self.connect()
            except Exception as ex:
                print('Error trying to reconnect... {}'.format(ex))
    

    Gijs



  • @Gijs I've been having this same issue for a long time.

    For me, the issue is fairly easily reproducible. Initialize the device in one location that has WIFI and let it get online. Load some code to it. Turn off the WIFI device itself (Or move somewhere outside of the range of it), and using REPL, send Ctrl-C to break out of the running code and try to connect to some other WIFI using commands so you can get it back online.

    from network import WLAN
    import machine
    wlan = WLAN(mode=WLAN.STA)
    wlan.connect(ssid='newWIFI', auth=(WLAN.WPA2, 'newwpapassword'))
    print( wlan.isconnected())
    pybytes.reconnect()
    

    It usually fails on the last line, pybytes.reconnect() despite all the rest succeeding.
    Sometimes I have to reboot and try again a dozen times before it fails in the right way to fix it.



  • I would like to add a constructive criticism. I really like the Pycom's products, but several times I have also felt like something is missing in the documentation. Sometimes it is the way it's organized, not so easy to browse it, other times some details are missing to quickly understand how things are working/designed or how should be configured, and sometimes it's not updated. In some way, I agree with this comment: "It sounds like you should do an audit of all your documentation". I know that I'm not the only one, I have read other people saying this kind of things.
    Pycom products are great, but you have to make your documentation easier to read, add all necessary details, do not assume that your users know all the internal details that you know. You have to create documentation as great as your products.



  • @Gijs
    We really haven't figured out how or why yet. Its seems that if the initial connection fails from the pybytes_config.json file then any subsequent pybytes methonds in the program or after you break and try commands from the REPL results in the above "NameErrror: name 'pybytes' isn't defined" message.

    Generally, if you reboot and are lucky to get a connection then the pybytes methods work as expected.

    Fortunately, since publishing this, we have stumbled into a pybytes_config.json file that does seem to connect up within 16 seconds every time, so its not a critical issue for us, but for a week or so it was quite frustrating.

    Thanks,

    Todd


  • Global Moderator

    Ive been working on that for the past ~2 months next to all other support, and haven't even gotten to the Pybytes section yet.. I know there are things missing and out of date and I understand your frustration.

    Now if you could let me know how to reproduce the issue of the pybytes library disappearing, I'm very much interested in solving that issue for you



  • @Gijs It sounds like you should do an audit of all your documentation. This stuff is hard enough even in the best of circumstances but when bad documentation leads you in to blind alleys for hours, it is mind-numbingly frustrating.


  • Global Moderator

    Hi,

    Im sorry you feel this way.
    Is there any way I can reproduce the issue you are describing? Perhaps can you give me an (actual) example I can try?
    The Pybytes library is positioned in the frozen-code section and is loaded at boot. The only reason I can think of, is that it would disappear is if the boot process was interrupted, or if all loaded items are cleared.

    As for the mistake in the documentation, it seems someone copied the connect_wifi(...) over to lte, without changing the parameters. I have the correct one for you here:

    connect_lte(activation_info=False, start_mqtt=True)
    

    Please let me know of other mistakes in the documentation so I can fix them!

    About the examples, thanks for the feedback. I thought we had some examples out there, but apparently we have none. I'll work on that!
    Best,
    Gijs


Log in to reply
 

Pycom on Twitter