Camera disconnects from IDE when running script (sometimes)

Hello,

So I am having an issue with the camera (M7) disconnecting when I try to run a script. I will click the green play button and it will hang for a few seconds, and then disconnect without running the script.

I saw this problem mentioned here: http://forums.openmv.io/viewtopic.php?t=315
I followed the three steps listed there:

  1. green button stays green indefinitely
  2. Frame buffer disabled, script runs indefinitely
  3. Frame buffer enabled, script runs indefinitely

This is true for all of the example scripts I have tried.

However, when I try to run my own script ( based mostly on example scripts ), is when the problem happens. I have noticed that if the file has been edited in a different text editor (in my case Vim and Sublime) the problem will happen. Furthermore, if I copy/paste code from another one of my scripts the problem happens. Lastly, sharing work with my group mates and implementing it in my own code will also cause this problem. If I remove the copy and pasted code, it WILL run the script, but if I then try to further edit that file within the IDE the script will not run and the camera disconnects. This is causing huge issues since it is making it very difficult to collaborate with my classmates without having this problem occur.

I am running OSX 10.12.3

Thanks in advance for any help!

Hi, there’s a work around for this in the mean time that might work for you.

  1. Disconnect from the camera.
  2. Go to tools - open terminal and open a serial terminal to your OpenMV Cam at 115200 baud.
  3. Then press enter and you should get REPL prompt.
  4. Edit code in the main window and then hit the green run button in the open Terminal window to send the script to the camera over REPL.
  5. To see what the camera sees add: print(img.compressed_for_ide()) at the end of the while loop.

Doing this bypasses our serial debug stack which seems to have an issue on MAC. I’d like to solve this problem but I can determine the exact issue because I can’t reproduce it. All my MACs I have work fine. I did write some code to solve what I thought the problem was… But, I don’t have a computer that has that same problem to test with.

If you’re willing to help me I can release a version of the IDE and the firmware with the fix I think will solve this issue. But, I need you to test and confirm it. The last guy didn’t respond after I put the work into fixing this issue to let me know if my fix worked.

Yep, I’d love to help!

I will be able to test the work around you provided in the next hour or so. Just let me know what I need to do to help.

I’ll build the test image thingy this weekend for you. The work around should keep you okay until then.

Okay I might need a little clarification on the work around.

My step 2 looks like: open terminal>new terminal>connect to serial port>[select serial port]cu.Blutooth-Incoming-Port>[baud rate] 115200

This opens up what looks like another serial terminal. But from here, when I connect the camera and click the green play button I don’t see any option to send the script to the camera over REPL. I think there is something I’m missing here.

The port you are selecting should not be a Bluetooth port. It should say cu.usb something.

Note that the secondary serial terminal overrides the ability for the main IDE to connect. It it connected correctly you should be able to press the enter button in the serial terminal window and get a repl prompt.

Um, see the OpenMV Video channel about the Open Terminal feature to see how to use this.

That was the only port available from the drop down. No usb option. In the mean time, we have been using my teammate’s Windows machine which runs the same scripts just fine. I’ll check out the video channel in the mean time. Thanks!

Weird… OpenMV IDE shouldn’t have been able to find the camera in the first place.

I’m also having trouble running a script from the main window on my mac.
The workaround via a serial terminal works fine, so I’m not blocked from continuing my work.
But let me know if I can help resolving this issue. :slight_smile:

Okay, I’m almost done releasing the next version of the IDE. It has the possible bug fix built-in but it will only activate it on firmware with a version of 9.9.9 so I’ll build a version of the firmware once I’m done releasing with the possible fix.

Awesome, thanks for your help. Will the new IDE version be on this site or the openmv github?

Also, do you think this is something that could be remedied by updating OSX to the latest version? Or is it more likely a usb port issue?

I honestly don’t know what causes this error. I believe it’s a hardware issue. As far as I understand the problem comes from the MAC hardware dropping USB bytes since we’re not using the USB CDC class in exactly the way it was designed for. I got a hint of the possible problem when a person showed me the USB trace and I saw the camera delivered the bytes to the application but the application did not receive all the data… meaning that bytes were dropped in the kernel.

So, I implemented some MTU learning code in the IDE. On first connect it will learn the max transfer size through the kernel and break up image reads by that. This trick doesn’t affect performance too much. (The IDE learns the MTU by doing image reads and checking to see how many bytes made it back… I have to bypass a lot of error checking in the IDE to make this work).

Anyway, please give me some time to release the next IDE version and I will then roll a version of the firmware with this fix. Please use the work around in the mean time.

Hi, here’s a version of the firmware that has the Mac MTU size fix implemented. The OpenMV Cam will send packets of data to the IDE that are of a max MTU size. Since I don’t have a computer with the failing issue I can’t tell if this fixes the error on my end but I can verify the code is working and breaking packets up. Load the firmware.bin file or openmv.dfu file. Either one will work.
openmv.zip (2.09 MB)

Hello, I believe I have this same issue. Running on a mac, and adding some characters to a working script (even if commented out) will cause a delay followed by the IDE disconnecting. I tried applying firmware.bin from your zip file by using the Tools->Run Bootloader option in the IDE. It seemed to update and I now have “Firmware Version 9.9.9” as reported at the bottom of the IDE. However it still does the hang disconnect. I’ve also attached a file I use to reproduce the issue.

Please let me know if there’s any update on this issue or anything I can test or do differently.
Thanks,
-Bob
helloworld_1.py (10.8 KB)

I have no idea what the problem is if it isn’t an MTU size issue…

The only way I can debug this is if I have a MAC which has the problem. All MAC computers that I’ve tried work fine without issue. I understand there’s a problem but I don’t know how to fix…

Um, if possible, can you install a USB trace analyzer program and send me the packet dump transaction? Yes, I understand this is a lot of work but I don’t know else to determine what is wrong.

Alternatively, use Windows or Linux. A linux or windows VM should not have problems.

Thank you very much for your reply. I completely understand.
I’m going to run with the serial terminal workaround for now. If I have time down the line I’ll see if I can get you those USB packet dumps.
Thanks,
-Bob

@kwagyeman I’m seeing this issue too. I’d be happy to install a USB trace analyzer and get some data for you! Do you have any recommendations for an analyzer? I will also verify tomorrow that the new IDE + FW 9.9.9 that you posted above doesn’t actually fix the issue as bobparadiso mentioned.

I found this:

https://aud-ios.com/2017/10/22/usb-monitoring-with-wireshark/.

I just need to see the traffic from OpenMV IDE to the OpenMV Cam. So, start logging before you hit connect. Then hit connect, you should see the logger print some stuff going on, then click the run button, afterwards please send a text dump of the transactions.

Maybe try this too?

http://vusb-analyzer.sourceforge.net/

I found wireshark last night as well. I’m getting data now - expect a message shortly :+1:

Hi, I uploaded a new version of the IDE with the fix here: http://upload.openmv.io/openmv-ide-mac-1.8.0.dmg

Give it a try.