Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@overrides(check_signature=False) runtime error #6

Open
akohlsmith opened this issue Feb 18, 2024 · 1 comment
Open

@overrides(check_signature=False) runtime error #6

akohlsmith opened this issue Feb 18, 2024 · 1 comment

Comments

@akohlsmith
Copy link

akohlsmith commented Feb 18, 2024

as of commit:f00b912 but also tried commit:2ea6a04 in the fix-overrides branch with the same result.

There are three places in hantek1008.py where this override code is used, and each errors out for the same reason:

    @overrides(check_signature=False)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: overrides() got an unexpected keyword argument 'check_signature'

If I comment the @overrides() line out the program does run, but after talking to the scope for several seconds the scope will reset (disconnect/reconnect to USB) and the program crashes:

$ python3 csvexport.py -s 1 -m -n 5000 /tmp/test.csv  -l debug

... several screens of very similar debug messages (short message to scope, long response from scope) ...

DEBUG  : >[ 2] a603
DEBUG  : <[64] ee07e407dd07d807d707d807e007df07ef07e407dc07d907d707d807e107e0070000000000000000000000000000000000000000000000000000000000000000
DEBUG  : delta: 0.0030 sec
DEBUG  : >[ 1] f6
DEBUG  : <[ 1] f6
DEBUG  : delta: 0.2164 sec
DEBUG  : >[ 1] e5
DEBUG  : <[ 2] 9b06
DEBUG  : delta: 0.0029 sec
Traceback (most recent call last):
  File "/home/andrew/hantek1008py/csvexport.py", line 581, in <module>
    main(selected_channels=args.channels,
  File "/home/andrew/hantek1008py/csvexport.py", line 138, in main
    device = connect(ns_per_div, vertical_scale_factor, selected_channels, correction_data, zero_offset_shift_compensation_channel,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andrew/hantek1008py/csvexport.py", line 215, in connect
    device.init()
  File "/home/andrew/hantek1008py/hantek1008.py", line 268, in init
    self._init3()
  File "/home/andrew/hantek1008py/hantek1008.py", line 356, in _init3
    assert response == bytes.fromhex("d606")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

If I comment out all of the assert response = ... lines in the _init3 function it seems to run and generates a csv file, although it does not seem to ever stop. I need to ^C out. It appears this is normal operation.

I'm running Python 3.11.2 on Ubuntu, and this is a 1008B purchased off of Amazon last week. lsusb output:

$ sudo lsusb -vs 2:24
[sudo] password for andrew:

Bus 002 Device 024: ID 0783:5725 C3PO YDJ-2088
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0783 C3PO
  idProduct          0x5725
  bcdDevice            2.00
  iManufacturer           1 YDJ-2088
  iProduct                2 YDJ-2088
  iSerial                 3 7
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0020
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              4 YDJ-2088
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0000
  (Bus Powered)
@mfg92
Copy link
Owner

mfg92 commented Feb 18, 2024

This project uses the overrides module. To have less runtime dependencies, the availability of overrides is optional; if overrides is missing, a dummy replacement is used instead. Back to your issue: This dummy was not compatible with the latest changes of the fix-overrides banch (and the fix-overrides branch was needed as the default behaviour of overrides had changed since this project was born). I have now adapted the dummy, so @OVERRIDES should no longer cause problems.

Please let me know your thoughts after testing. Unfortunately, I am not able to test it myself as I no longer have access to a Hantek 1008.

Now for the assert statements: They exist because I noticed at the time that the respective responses on my device were always the same. I was not able (nor was there any need) to find out what the response meant, but I wanted to be notified if the response changed for any reason, hence the assert. It does make sense that you might get different answers with a different copy of the unit (or perhaps the firmware/hardware has changed slightly in the last 6 years). To make a long story short: It's OK to remove or adapt these asserts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants