Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <[email protected]>
  • Loading branch information
Ho-Ro committed Feb 5, 2020
1 parent 592b120 commit c8fa3ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fw_custom_BL:

install: all
python3 setup.py install
cp 60-hantek-6022-usb.rules /etc/udev/rules.d/
if [ -d /etc/udev/rules.d/ ]; then cp 60-hantek-6022-usb.rules /etc/udev/rules.d/; fi

deb:
fakeroot checkinstall --default --requires python3-libusb1 --install=no --backup=no --deldoc=yes
Expand Down
6 changes: 2 additions & 4 deletions PyHT6022/LibUsbScope.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = 'Robert Cope', 'Jochen Hoenicke'

import sys
import os
import time
import usb1
import array
Expand All @@ -9,8 +9,6 @@
import threading
from struct import pack

isPython3 = '3' == sys.version[0]

from PyHT6022.HantekFirmware import custom_firmware_BE, custom_firmware_BL, fx2_ihex_to_control_packets

class Oscilloscope(object):
Expand Down Expand Up @@ -155,7 +153,7 @@ def open_handle(self):
if not self.device and not self.setup():
return False
self.device_handle = self.device.open()
if self.device_handle.kernelDriverActive(0):
if os.name == 'posix' and self.device_handle.kernelDriverActive(0):
self.device_handle.detachKernelDriver(0)
self.device_handle.claimInterface(0)
if self.is_device_firmware_present:
Expand Down
7 changes: 4 additions & 3 deletions examples/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from PyHT6022.LibUsbScope import Oscilloscope

import sys
import time
import binascii

Expand Down Expand Up @@ -180,13 +179,15 @@ def read_avg( voltage_range, sample_rate=110, repeat = 1, samples = 12 * 1024 ):

if ( create_config ):
# write integer offset for low speed sampling into config file
# add this value to get zero calibration
voltID = V_div[ index ]
if ( abs( offlo1[ gainID ] ) <= 25 ): # offset too high -> skip
config.write( "ch0\\%dmV=%d\n" % ( voltID, 0x80 + offlo1[ gainID ] ) )
config.write( "ch0\\%dmV=%d\n" % ( voltID, -offlo1[ gainID ] ) )
if ( abs( offlo2[ gainID ] ) <= 25 ): # offset too high -> skip
config.write( "ch1\\%dmV=%d\n" % ( voltID, 0x80 + offlo2[ gainID ] ) )
config.write( "ch1\\%dmV=%d\n" % ( voltID, -offlo2[ gainID ] ) )

# prepare eeprom content
# store values in offset binary format (zero = 0x80, as in factory setup)
if ( abs( offlo1[ gainID ] ) <= 25 ): # offset too high -> skip
ee_calibration[ 2 * index ] = 0x80 + offlo1[ gainID ] # CH1 offset integer part
if ( abs( offlo_1[ gainID ] ) <= 125 ): # frac part not plausible
Expand Down

0 comments on commit c8fa3ab

Please sign in to comment.