Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    LoPy vs L01 (OEM module)

    Scheduled Pinned Locked Moved LoPy
    lopylopy oemloramac
    7 Posts 3 Posters 812 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      Anthony
      last edited by

      I have simple LoRa raw code that runs perfectly fine with two LoPy devices talking to each other. But the same simple code causes the exception error #11 EAGAIN when running on an L01 module. Pybytes, Device, Firmware, Python, and MicroPython all report the same on both devices. The code and output (from the L01) is shown below. The L01 always crashes on the 4th 'ping' from socket.send().

      Is there some difference between the LoPy and the L01 OEM that requires a different LoRa setup or firmware version?

      Code

      from network import LoRa
      import socket
      import machine
      import time
      import uos
      import sys
      from network import Bluetooth
      
      lora = LoRa(mode=LoRa.LORA, region=LoRa.US915)
      s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
      
      print("PING Unit")
      
      print('Device: ' + uos.uname().machine)
      print('Firmware: ' + uos.uname().release)
      print('Python: ' + sys.version)
      print('MicroPython: ' + str(sys.implementation.version[0]) + '.' + str(sys.implementation.version[1]) + '.' + str(sys.implementation.version[2]))
      print('===============================================================================')
      
      print('Switching off Bluetooth')
      bt = Bluetooth()
      bt.deinit()
      
      s.setblocking(False)
      while True:
      	print("Send 'Ping'")
      	s.send('Ping')
      
      	print("Waiting...")	
      	data = s.recv(64)
      	print(data)
      	if s.recv(64) == b'Pong':
      		print("Got 'Pong'")
      		
      	time.sleep(2)
      

      Output
      0_1543791205827_e8cfb5d5-d271-44ac-84c8-decd30e63496-image.png ![alt text](image url)

      M robert-hhR 2 Replies Last reply Reply Quote 0
      • M Offline
        mgranberry @Anthony
        last edited by

        I think you might have intended if s.recv(64) == b'Pong': to be if data == b'Pong':. I think you have an empty buffer.

        A 1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @Anthony
          last edited by

          @anthony The difference between LoPy (assuming LoPy 1) and L01 is the memory size. L01 has 4 MB SPIRAM, which LoPy1 does not have. That affects the timing of code. LoPy1 runs slightly faster. Especially external events are served faster.

          A 1 Reply Last reply Reply Quote 0
          • A Offline
            Anthony @mgranberry
            last edited by

            @mgranberry This code as-is will work fine with two LoPy boards that ping each other back and forth. The error actually occurs with the "s.send()" line. If I take the receive code out and just have the send and the sleep I will still get "EAGAIN".

            1 Reply Last reply Reply Quote 0
            • A Offline
              Anthony @robert-hh
              last edited by

              @robert-hh Do you know how or why this would cause error #11 from the LoRa send command in the code example I listed? Even at its slowest I would assume the LoRa can push ~180 bps, so sending 4 chars every 2 seconds should be easy?

              robert-hhR 1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @Anthony
                last edited by

                @anthony The transmission speed is the same for both devices. But as @mgranberry pointed out, the program logic is wrong in two aspects:
                a) s is set nonblocking. That means, the code will continue immediately once s.send() was called, not waiting for the data to be sent. Similar, the immediately s.recv() will return immediately with either the data which as received beforehand, or None. So at the print statement "Waiting..." it does not wait. The code waits after the second s.recv()
                b) you call s.recv() twice in a loop (that's what @mgranberry expressed with his comment).
                The whole code is similar to the examples here https://github.com/pycom/pycom-libraries/tree/master/examples/lopy-lopy

                1 Reply Last reply Reply Quote 0
                • A Offline
                  Anthony
                  last edited by

                  In case anybody else has this problem. In our case it was either a defective L01 OEM module or a manufacturing defect with the PCB. We built a second unit and the LoRa worked fine in that L01 module. It did not hang or crash, and the LoRa pings worked fine over several minutes of testing.

                  1 Reply Last reply Reply Quote 1

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • 1 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom