Socket timeout(None) not respected (or some other issue)

Hello - I’m using 2 cams with WiFi shield and latest Winc drivers - First one runs a streamer script that sits and waits for a web client to start streaming. This one is happy to sit there waiting, and web-clients can come and go. Life is good when pulling the stream via web-clients…

The other one has to open the socket and push the stream… rather than a web-client and the Open-MV as server, this one is the client for an ESP32 acting as the socket server who listens and waits for the OpenMV to power-up and open the socket and push frames to the ESP… (who then writes to the frame buffer of an attached touchscreen display…) This also works fine except for the life of me I can’t seem to get it to respect the timeout “None” in the documentation.

It seems to get unhappy sitting and waiting at the readline() for more than 10 seconds. It doesn’t just close the network socket, it actually disconnects from the IDE (or when running on its own, seems to abort requiring a power reset… Anything to point me to to keep this puppy alive waiting to read from the server to advance the loop to stream the next frame?

s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
addr = usocket.getaddrinfo('', 80)[0][-1]

then later 

while (True):
    clock.tick() # Track elapsed milliseconds between snapshots()
    frame = sensor.snapshot()  # Takes the photo
    cframe = frame.compressed(quality=25)  #
    header = "Content-Length:"+str(cframe.size())
    sig = s.readline()

An exception is probably happening and you need to handle it.

However, the disconnection from the IDE implies a crash is happening. Is this the shortest snippet to produce the error?


Hi - thanks - is there a comprehensive list of LED flash codes?

Everything works from IDE but when I externally power the OpenMV (connected to the MCU sitting in the same state, waiting for the OpenMV to power-up, connect and start streaming (have removed any readline()s so its just got to connect and stream.)

If I use the IDE to connect the plug icon and then hit the play (run script) - everything works.

If I power the camera externally - it doesn’t seem to even start the script. Not sure how to figure out what its doing…

Here’s a video and attaching the code below…

Appreciate your help - anything you can do to point me in the right direction?

(Attachment IDEwUSBvs5Vexternal.mp4 is missing) (1.84 KB)

Uploaded video to youtube

Here’s a video showing IDE and external power cases in action.,…

Thanks for the video.

So, I’d check the following:

  1. Run the script from the IDE, then apply 5V power, then disconnect the USB cable from the camera. It should continue running. If your script does not continue running it means the power supply is not working well.

  2. If the script is saved to the camera and the camera is attached to your PC via USB without the IDE being connected then the camera should start to run your script after about 5 seconds. If this does not happen then the script is not saved to the camera. Please make sure to save the script by using the Tools->IDE Save Script to camera feature and then safety remove the USB flash drive of the OpenMV Cam. Note that if you use a SD card the reliability of this improves dramatically (it’s because the OS will switch from FAT12 to FAT16/32 drivers which actually write the disk file data out versus treating the OpenMV Cam like a floppy disk drive).

  3. If both of these pass then the camera should work from the 5V PSU. If not then please check the current limit on the PSU.

AH Ok - thanks for that! I just did the switch to external power while running (yanked out the USB). The script kept running without missing a beat.

here’s a video of that working

(and i can now see it drawing 245mv just like the Front OpenMV does (this is the Rear OpenMV).

So i’m not actually saving anything when I use the IDE to save current script as…

I’m not using any SD cards at all. Doesn’t the cam have enough space for this tiny streamer script on its onboard memory? The front one seems to be happy (the script is quite similar in size)…

What steps should I try to get this cam to actually install to be this script? Any ideas?

OK - I just erased on board flash and saved again over and over - after 5 or 6 tries its now working - THANKS!

OK so I’ve got an aftermarket wide-angle on the cam. Are the 2 bright spots artifacts of perhaps no IR filter? (i’ve ordered wide angle from your store - should arrive soon).

Could be. It’s hard to tell.

If it’s not moving it’s dirt on the lens. If it’s moving then it’s likely IR light.