Announcement

Collapse
No announcement yet.

Problems syncing using Python on Windows 10

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems syncing using Python on Windows 10

    Hello!

    I'm using python trying to sync the camera to capture a few pictures using my own program. Nevermind the ugly code.



    import serial as Ser
    import time

    cam=Ser.Serial(baudrate=115200, timeout=1, port='COM3')
    print(cam.name)
    sync=b'0xAA0D 0x00 0x00 0x00 0x00'
    i=0
    print(sync)


    while i < 49:
    try:
    while not cam.in_waiting and i < 50:
    cam.write(sync)
    print(i)
    time.sleep(0.01)
    i=i+1
    print(cam.in_waiting)

    if i == 50:
    print('Camera not responding')
    break
    if cam.in_waiting:
    print('CamInwait')
    print(cam.in_waiting)
    a=cam.readline(cam.in_waiting)
    print(a)
    break
    finally:
    cam.close()


    According to the datasheet section 6: the correct sync command should be 0xAA0D 0x00 0x00 0x00 0x00 correct?

    No matter what I assign to "sync", be it "0xAA 0x0D 0x00 0x00 0x00 0x00 "AA 0D 00 00 00 00" or "aofbasdfhj" or any variation of the hex representation, the readline returns similar lines - b'\x98\xe6\xfe\x80\x00\x80\x98\x1e0\x00'

    Somtimes print(cam.in_waiting) prints 10, other times 20, with slightly different output - b'\x98\xe6\xfe\x80\x00\x86\x98\x1e0\x00\x98\xe6\xfe\x80\x00\x98\x98\x1e\x18\x00'


    If I use baudrate = 57600
    I get a bit different outputs as well. Sometimes the buffer contains 32 bytes, other times 20, sometimes 12, etc.

    CamInwait
    32
    b'\xaa\x0f\x00e\r\x00\xaa\x0f\x00f\r\x00\xaa\x0f\x00g\r\x00\xaa\x0f\x00h\r\x00\xaa\x0f\x00i\r\x00\xa a\x0f'

    Which, I interpret as a NAK




    Could you shed some light on what's going on? Thanks. I'm using windows 10 and via a FTID ttl-usb 3.3v.







    The camera works perfectly using Workshop 4D.
    Also, it was delivered with a slight crack in the glass under the lens.
Working...
X