No announcement yet.

Gen4-ulcd Diablo16 display -Raspi3 python

  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Hi Mark,

    Basically, to query the object, you need to send 4 bytes only not 6 bytes and to observe this, you could use GTX tool for this.

    I have attached a simple python script to demonstrates the genieReadObject().

    If you have questions, please don't hesitate to ask.

    Best regards,
    Attached Files


    • mchollett
      mchollett commented
      Editing a comment
      Thanks for your help.

      I also wanted to mention that the 4D Systems document titled - "ViSi Genie Writing to Genie Objects Using an Arduino Host" was very helpful in learning how to write to the screen. I was disappointed that there is not a companion document on reading ogjects.

      Thanks again for your help

    • mchollett
      mchollett commented
      Editing a comment
      I've worked your example into my code and get a 6 byte string when I request the value of Leddigits0.

      This is a print out of the buffer I'm using for troubleshooting

      processing buffer response
      item in buffer was a report object
      0 b'\x05'
      1 b'\x0f'
      2 b'\x00'
      3 b'\x00'
      4 b'\xba'
      5 b'\xb0'
      [b'\x05', b'\x0f', b'\x00', b'\x00', b'\xba', b'\xb0']
      end of processing object response

      I've come up with what I think is an overly complicated way to convert the response into a decimal readout.

      Should be 186

      Can you suggest some python code to get a decimal value from the above example ?

      Last edited by mchollett; 17th January 2019, 04:19 AM.

  • #17
    Hi mchollett,

    As you know, report object comprises 6 bytes and each byte represents data.
    Below is the order of data bytes received from report object.

    Click image for larger version  Name:	attached.PNG Views:	5 Size:	6.8 KB ID:	66724

    To get the value sent by the object you will need the msb and lsb data bytes. In your case, 0x00 and 0xba.
    Note that the msb corresponds the high byte of the value and lsb for low byte of the value.

    Kindly refer to ViSi-Genie Reference Manual for additional information with regards to the ViSi-Genie protocol.

    Below the python code implementation in converting value data bytes to dec.
    msb = 0x00
    lsb = 0xba
    highByte = msb<<8 # bit shift lsb
    lowByte = lsb
    res = highByte^lowByte #xor operation
    Output: 186

    Best regards,
    Attached Files
    Last edited by Vince_4D; 18th January 2019, 12:21 PM. Reason: msb and lsb were interchanged with respect to the given data


    • mchollett
      mchollett commented
      Editing a comment
      Thanks for your example. I had trouble with your example as I think Python pulls strings from the serial port with the standard read. This is the code I ended up with

      I read the individual items with a loop and create a list of the items called line []. From the above example:

      line[b'\x05', b'\x0f', b'\x00', b'\x00', b'\xba', b'\xb0']

      ledmsb = line[3].hex() # high byte of value
      ledlsb = line[4].hex() # low byte of value
      leddigit_value = int((ledmsb + ledlsb),16)

      Thanks again for your help.

    • Vince_4D
      Vince_4D commented
      Editing a comment
      Hi mchollett,

      I think you forgot the bit shifting part.
      You were still able to get the correct value on your computation because the msb in the given example is 0x00, thus, will not affect the computation. But for values of msb not equal to 0x00, it will fail.

      Try implementing as follows:

      >>> msb = int(list[3].hex(),16)
      >>> lsb = int(list[4].hex(),16)
      >>> msb = msb << 8
      >>> value= msb + lsb

    • mchollett
      mchollett commented
      Editing a comment
      Got it.... Thanks