Hi! I was getting 0.00% on the print that I highlighted and I was wondering why was that happening? For context, this is the call script of the RPC module.
def get_frame_buffer_call_back(pixformat_str, framesize_str, cutthrough, silent):
if not silent:
print("Getting Remote Frame...")
result = interface.call("jpeg_image_snapshot", "%s,%s" %
(pixformat_str, framesize_str))
if result is not None:
size = struct.unpack("<I", result)[0]
img = bytearray(size)
print(1)
if cutthrough:
# Fast cutthrough data transfer with no error checking.
# Before starting the cut through data transfer we need to sync both the master and the
# slave device. On return both devices are in sync.
result = interface.call("jpeg_image_read")
if result is not None:
# GET BYTES NEEDS TO EXECUTE NEXT IMMEDIATELY WITH LITTLE DELAY NEXT.
# Read all the image data in one very large transfer.
interface.get_bytes(img, 5000) # timeout
else:
# Slower data transfer with error checking.
# Transfer 32 KB chunks.
chunk_size = (1 << 15)
if not silent:
print("Reading %d bytes..." % size)
for i in range(0, size, chunk_size):
ok = False
for j in range(3): # Try up to 3 times.
result = interface.call(
"jpeg_image_read", struct.pack("<II", i, chunk_size))
if result is not None:
img[i:i+chunk_size] = result # Write the image data.
if not silent:
print(“%.2f%%” % ((i * 100) / size))
ok = True
break
if not silent:
print("Retrying... %d/2" % (j + 1))
if not ok:
if not silent:
print("Error!")
return None
return img
else:
if not silent:
print("Failed to get Remote Frame!")
return None
What operating system are you on? I can confirm it works fine on windows. The timeouts in the code are likely too short. Another forum user had an issue with this.
Mmm, I’ll have to debug that using a USB packet analyzer. Most likely the timing is off causing the library to not work. It’s really hard to debug via USB.
If you can switch to the UART master? That should work.
The issue is probably related to how pyserial buffers data on the pi. I’ll have to debug this manually and possibly make the library act different on the Pi.
…
To be clear, try editing this class:
The get_bytes method. You can add a print there. If you see that method timing out then just making the timeouts bigger should fix the issue.
Verify the library is saved and then restart the camera. This will make the camera VCP timeout 10X longer. This will negatively affect performance for short data transfers but not affect longer ones.
This is interesting… I ran the test scripts for the RPC in python2 and it ran perfectly. It seems there is a problem with running it on python3. Maybe what you mentioned about the serial connection.