baryluk / fnirsi-usb-power-data-logger

Driver / Data logger for FNIRSI FNB48, FNIRSI C1 and FNIRSI FNB58 USB Power meter
MIT License
152 stars 17 forks source link

How to run it with FNB58 ? #2

Closed yildirayk closed 1 year ago

yildirayk commented 1 year ago

Fnirsi released the new version of their usb meters, Fnb58. How can I use your code with it ? What modifications do I need to make? At the moment, "device not found" is thrown. Have you tested it with the new device ? Thanks

baryluk commented 1 year ago

@yildirayk Thanks for the info. The new meter FNB58 looks really nice.

I do not own it at the moment. I might get one, eventually, but for the time being you could provide some information as I expect it to be using the same protocol, and just shows as a different USB device device id.

Assuming you are on Linux, plug the device and check the last few lines of the dmesg command output.

Also please provide output of lsusb command.

yildirayk commented 1 year ago

dmesg gives,

... [16451.322995] xhci_hcd 0000:3a:00.0: xHCI Host Controller [16451.323039] xhci_hcd 0000:3a:00.0: new USB bus registered, assigned bus number 3 [16451.324275] xhci_hcd 0000:3a:00.0: hcc params 0x200077c1 hci version 0x110 quirks 0x0000000200009810 [16451.325105] xhci_hcd 0000:3a:00.0: xHCI Host Controller [16451.325229] xhci_hcd 0000:3a:00.0: new USB bus registered, assigned bus number 4 [16451.325252] xhci_hcd 0000:3a:00.0: Host supports USB 3.1 Enhanced SuperSpeed [16451.325387] usb usb3: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.15 [16451.325403] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [16451.325416] usb usb3: Product: xHCI Host Controller [16451.325425] usb usb3: Manufacturer: Linux 5.15.0-52-generic xhci-hcd [16451.325432] usb usb3: SerialNumber: 0000:3a:00.0 [16451.326800] hub 3-0:1.0: USB hub found [16451.326925] hub 3-0:1.0: 2 ports detected [16451.330930] usb usb4: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.15 [16451.330947] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [16451.330956] usb usb4: Product: xHCI Host Controller [16451.330964] usb usb4: Manufacturer: Linux 5.15.0-52-generic xhci-hcd [16451.330971] usb usb4: SerialNumber: 0000:3a:00.0 [16451.331924] hub 4-0:1.0: USB hub found [16451.331963] hub 4-0:1.0: 2 ports detected

and lsusb gives

Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 8087:0a2b Intel Corp. Bluetooth wireless interface Bus 001 Device 002: ID 064e:3401 Suyin Corp. HP TrueVision FHD RGB-IR Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

yildirayk commented 1 year ago

If I start the device in boot mode and then dmesg,

[16885.928814] pci_bus 0000:04: busn_res: [bus 04] is released [16885.928894] pci_bus 0000:05: busn_res: [bus 05-39] is released [16885.929009] pci_bus 0000:3a: busn_res: [bus 3a] is released [16885.929122] pci_bus 0000:03: busn_res: [bus 03-3a] is released [17399.575208] usb 1-1: new full-speed USB device number 13 using xhci_hcd [17399.725285] usb 1-1: New USB device found, idVendor=0483, idProduct=0038, bcdDevice= 2.00 [17399.725301] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [17399.725308] usb 1-1: Product: FNB-58 [17399.725313] usb 1-1: Manufacturer: FNIRSI [17399.725318] usb 1-1: SerialNumber: 082A4A7F7048 [17399.765616] usbcore: registered new interface driver cdc_acm [17399.765625] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters [17399.769832] usb-storage 1-1:1.0: USB Mass Storage device detected [17399.770144] scsi host0: usb-storage 1-1:1.0 [17399.770498] usbcore: registered new interface driver usb-storage [17399.773395] input: FNIRSI FNB-58 as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.3/0003:0483:0038.0008/input/input37 [17399.773731] hid-generic 0003:0483:0038.0008: input,hidraw2: USB HID v1.10 Device [FNIRSI FNB-58] on usb-0000:00:14.0-1/input3 [17399.773849] usbcore: registered new interface driver usbhid [17399.773853] usbhid: USB HID core driver [17399.775174] usbcore: registered new interface driver uas [17400.784511] scsi 0:0:0:0: Direct-Access FNIRSI FNB58 2.00 PQ: 0 ANSI: 0 CCS [17400.785368] sd 0:0:0:0: Attached scsi generic sg0 type 0 [17400.785999] sd 0:0:0:0: [sda] 3072 4096-byte logical blocks: (12.6 MB/12.0 MiB) [17400.786188] sd 0:0:0:0: [sda] Write Protect is off [17400.786198] sd 0:0:0:0: [sda] Mode Sense: 00 00 00 00 [17400.786378] sd 0:0:0:0: [sda] Asking for cache data failed [17400.786392] sd 0:0:0:0: [sda] Assuming drive cache: write through [17400.795579] sda: [17400.796923] sd 0:0:0:0: [sda] Attached SCSI removable disk [17401.623586] FAT-fs (sda): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. [17410.098545] usb 1-1: USB disconnect, device number 13

yildirayk commented 1 year ago

VID = 0x1d6b PID_FNB58 = 0x0003

if I do like this, I don't get "device not found" but

Traceback (most recent call last): File "/home/yildiray/Downloads/Fnirsi/./fnirsi_logger.py", line 184, in main() File "/home/yildiray/Downloads/Fnirsi/./fnirsi_logger.py", line 38, in main dev.reset() File "/usr/lib/python3/dist-packages/usb/core.py", line 961, in reset self._ctx.backend.reset_device(self._ctx.handle) File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 911, in reset_device _check(self.lib.libusb_reset_device(dev_handle.handle)) File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 604, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno None] Other error

didim99 commented 1 year ago

Colleagues, I have the FNB58 device too and also tried to adopt @baryluk's script for this tester but it is not as easy as we would like. I figured out what VID/PID FNB58 uses in communication mode: 2e3c:5558 and tried put it to script configuration. Unfortunately, it doesn't work. I got a exception described below:

Traceback (most recent call last):
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/fnirsi_logger.py", line 184, in <module>
    main()
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/fnirsi_logger.py", line 96, in main
    ep_out.read(size_or_buffer=64)
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/core.py", line 423, in read
    return self.device.read(self, size_or_buffer, timeout)
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/core.py", line 1029, in read
    ret = fn(
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/backend/libusb1.py", line 846, in bulk_read
    return self.__read(self.lib.libusb_bulk_transfer,
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/backend/libusb1.py", line 954, in __read
    _check(retval)
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out

Unlike of previous devices from FNIRSI, FNB58 provides not a single interface but set of interfaces, as described below (output from pyusb), and first of them is USB Mass Storage.

DEVICE ID 2e3c:5558 on Bus 003 Address 069 =================
 bLength                :   0x12 (18 bytes)
 bDescriptorType        :    0x1 Device
 bcdUSB                 :  0x200 USB 2.0
 bDeviceClass           :    0x0 Specified at interface
 bDeviceSubClass        :    0x0
 bDeviceProtocol        :    0x0
 bMaxPacketSize0        :   0x40 (64 bytes)
 idVendor               : 0x2e3c
 idProduct              : 0x5558
 bcdDevice              :  0x200 Device 2.0
 iManufacturer          :    0x1 FNIRSI
 iProduct               :    0x2 FNB-58
 iSerialNumber          :    0x3 07AECA927048
 bNumConfigurations     :    0x1
  CONFIGURATION 1: 100 mA ==================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0x92 (146 bytes)
   bNumInterfaces       :    0x4
   bConfigurationValue  :    0x1
   iConfiguration       :    0x0 
   bmAttributes         :   0xc0 Self Powered
   bMaxPower            :   0x32 (100 mA)
    INTERFACE 0: Mass Storage ==============================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :    0x8 Mass Storage
     bInterfaceSubClass :    0x6
     bInterfaceProtocol :   0x50
     iInterface         :    0x0 
      ENDPOINT 0x84: Bulk IN ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x84 IN
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0
      ENDPOINT 0x4: Bulk OUT ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x4 OUT
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0
    INTERFACE 1: CDC Communication =========================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x1
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x1
     bInterfaceClass    :    0x2 CDC Communication
     bInterfaceSubClass :    0x2
     bInterfaceProtocol :    0x1
     iInterface         :    0x0 
      ENDPOINT 0x82: Interrupt IN ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x82 IN
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0xa
    INTERFACE 2: CDC Data ==================================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x2
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :    0xa CDC Data
     bInterfaceSubClass :    0x0
     bInterfaceProtocol :    0x0
     iInterface         :    0x0 
      ENDPOINT 0x81: Bulk IN ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0
      ENDPOINT 0x1: Bulk OUT ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x1 OUT
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0
    INTERFACE 3: Human Interface Device ====================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x3
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :    0x3 Human Interface Device
     bInterfaceSubClass :    0x0
     bInterfaceProtocol :    0x0
     iInterface         :    0x0 
      ENDPOINT 0x83: Interrupt IN ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x83 IN
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0xa
      ENDPOINT 0x3: Interrupt OUT ==========================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x3 OUT
       bmAttributes     :    0x3 Interrupt
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0xa

I tried to correct script to determine what interface is HID and use its number in line intf = cfg[(0, 0)] instead of hardcoded 0, 0 and get correct interface/endpoints. But it still not works due to the following error:

Traceback (most recent call last):
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/fnirsi_logger.py", line 188, in <module>
    main()
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/fnirsi_logger.py", line 104, in main
    ep_out.write(b"\xaa\x83" + b"\x00" * 61 + b"\x9e")
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/core.py", line 408, in write
    return self.device.write(self, data, timeout)
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/core.py", line 989, in write
    return fn(
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/backend/libusb1.py", line 855, in intr_write
    return self.__write(self.lib.libusb_interrupt_transfer,
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/backend/libusb1.py", line 938, in __write
    _check(retval)
  File "/home/didim/tmp/fnirsi-usb-power-data-logger/venv/lib/python3.8/site-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out

Thus we need a bit more research and reverse-engineering of FNB58 communication protocol to make it work. I hope this information helps you.

P. S. I created PR with my work, maybe this code will be useful for further development.

baryluk commented 1 year ago

Indeed, the FNB58 looks substantially different from FNB48 and C1. For example it has also the small USB storage device. Likely the protocol changed.

@didim99 I used wireshark with Windows and Windows app for these meters, running in kvm / qemu, to dig at the protocol level and initialization. I was a complete USB noob, but it was not too hard and figure it out.

didim99 commented 1 year ago

@baryluk yes, Wireshark is great util. There is no serious difference in communication protocol from FNB48, just couple lines of code to make it works, see next PR. @yildirayk please test corrected script with your FNB58 device, it should work.

yildirayk commented 1 year ago

I tried it with your updated scripts, with both of your branches, @baryluk @didim99 I still doesn't work in my case. If I run it with the vendor and product ID's,

VID_FNB58 = 0x2e3c
PID_FNB58 = 0x5558

It doesn't detect the device. If I run it with the vendor and product IDs as I wrote in the fifth comment, it doesn't complain about device not getting found, but throws the error mentioned in that post.

@didim99 How do you get the pyusb output that you wrote in the sixth comment ? What do you run ?

didim99 commented 1 year ago

@yildirayk are you sure what your lsusb output is complete? I don't see any strings related to FNB58, these looks like this:

Bus 003 Device 058: ID 2e3c:5558 FNIRSI FNB-58

And related dmesg output is:

[360257.700807] usb 3-1: new full-speed USB device number 59 using xhci_hcd
[360257.874768] usb 3-1: New USB device found, idVendor=2e3c, idProduct=5558, bcdDevice= 2.00
[360257.874774] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[360257.874776] usb 3-1: Product: FNB-58
[360257.874777] usb 3-1: Manufacturer: FNIRSI
[360257.874779] usb 3-1: SerialNumber: 07AECA927048
[360257.906807] usb-storage 3-1:1.0: USB Mass Storage device detected
[360257.907141] scsi host6: usb-storage 3-1:1.0
[360257.914904] input: FNIRSI FNB-58 as /devices/pci0000:00/0000:00:08.1/0000:0b:00.3/usb3/3-1/3-1:1.3/0003:2E3C:5558.00A7/input/input207
[360257.914986] hid-generic 0003:2E3C:5558.00A7: input,hidraw8: USB HID v1.00 Device [FNIRSI FNB-58] on usb-0000:0b:00.3-1/input3
[360258.910239] scsi 6:0:0:0: Direct-Access     FNIRSI   FNB58            2.00 PQ: 0 ANSI: 0 CCS
[360258.910502] scsi 6:0:0:0: Attached scsi generic sg4 type 0
[360258.911044] sd 6:0:0:0: [sdd] 3072 4096-byte logical blocks: (12.6 MB/12.0 MiB)
[360258.911194] sd 6:0:0:0: [sdd] Write Protect is off
[360258.911197] sd 6:0:0:0: [sdd] Mode Sense: 00 00 00 00
[360258.911342] sd 6:0:0:0: [sdd] Asking for cache data failed
[360258.911347] sd 6:0:0:0: [sdd] Assuming drive cache: write through
[360258.918803]  sdd:
[360258.919817] sd 6:0:0:0: [sdd] Attached SCSI removable disk
[360259.600327] FAT-fs (sdd): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

To see output from pyusb just use print(dev).

yildirayk commented 1 year ago

Ok, I made a small progress.

When I keep pressing the wheel button at the top (boot mode or communication mode ?) and then connect to the USB, (ignoring "press back to go to the app" prompt appearing at the screen of the device)

then I can list it in lsusb

Bus 001 Device 005: ID 0483:0038 STMicroelectronics FNB-58

and the python script outputs,

DEVICE ID 0483:0038 on Bus 001 Address 005 =================
 bLength                :   0x12 (18 bytes)
 bDescriptorType        :    0x1 Device
 bcdUSB                 :  0x200 USB 2.0
 bDeviceClass           :    0x0 Specified at interface
 bDeviceSubClass        :    0x0
 bDeviceProtocol        :    0x0
 bMaxPacketSize0        :   0x40 (64 bytes)
 idVendor               : 0x0483
 idProduct              : 0x0038
 bcdDevice              :  0x200 Device 2.0
 iManufacturer          :    0x1 FNIRSI
 iProduct               :    0x2 FNB-58
 iSerialNumber          :    0x3 082A4A7F7048
 bNumConfigurations     :    0x1

timestamp sample_in_packet voltage_V current_A dp_V dn_V temp_C_ema energy_Ws capacity_As
Traceback (most recent call last):
  File "/home/yildiray/Downloads/fnirsi-utils-master/./fnirsi_logger.py", line 194, in <module>
    main()
  File "/home/yildiray/Downloads/fnirsi-utils-master/./fnirsi_logger.py", line 185, in main
    data = ep_in.read(size_or_buffer=64, timeout=1000)
  File "/usr/lib/python3/dist-packages/usb/core.py", line 423, in read
    return self.device.read(self, size_or_buffer, timeout)
  File "/usr/lib/python3/dist-packages/usb/core.py", line 1029, in read
    ret = fn(
  File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 864, in intr_read
    return self.__read(self.lib.libusb_interrupt_transfer,
  File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 954, in __read
    _check(retval)
  File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out

Still crushes, any idea ?

didim99 commented 1 year ago

@yildirayk when you connect tester with pressed wheel button it starts to bootloader mode (only for firmware upgrade). For normal (communication, data acquiring) mode you just need to connect tester without pressing any button. And last thing what I want to check: what version of the firmware installed on your device? If it a very old, the firmware can probably not yet supports PC communication at all. Then you need to upgrade it to last version (on v0.63 communication works properly).

yildirayk commented 1 year ago

The first thing I did after receiving the product was to firmware update. Yes, it is on v0.63. I use Ubuntu 22.04 LTS

Observation 1 : I cannot list the device in normal mode. lsusb doesn't list it. Only sees it in bootloader mode.

Observation 2 : In bootloader mode, if I try to run it with VID=0483 and PID=0038, it crushes on @didim99 's branch and it runs on @baryluk 's branch. But it runs without reading anything

timestamp sample_in_packet voltage_V current_A dp_V dn_V temp_C_ema energy_Ws capacity_As 1667771637.781 0 0.00055 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.791 1 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.801 2 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.811 3 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.785 0 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.795 1 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.805 2 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.815 3 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.794 0 0.00055 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.804 1 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.814 2 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000 1667771637.824 3 0.00000 0.00000 0.000 0.000 0.000 0.000000 0.000000

I think it is dangerous to try it in bootloader mode. So I will stick to the normal mode. But my computer doesn't see/list it in normal mode :( How can I make it visible in normal mode ?

I am using type-C-in output of the device to connect to the computer. Do you use the same port @didim99 ? In my computer, there are USB type-A and type-C ports. I am trying on all of them.

baryluk commented 1 year ago

On my FNB48 ( I do not have FNB58) there is a switch to enable / disable PC comms. Afaik there migth also be some setting in menus.

I am using type-C-in output of the device to connect to the computer.

I think you should be using micro USB port marked PC to connect to the computer.

didim99 commented 1 year ago

~@yildirayk run dmesg -w then plug in tester in normal mode and see in terminal, are any new lines here? If no, probably your tester/cable/USB-prot is broken, try to use another port/cable/computer to check them all. Also you can try to upgrade firmware to latest version (0.65), but I don't think that's the issue.~

I am using type-C-in output of the device to connect to the computer.

Okay, there is root of issue. It's totally wrong. You should use microUSB port marked as 🖥 PC and then all will work.

didim99 commented 1 year ago

@baryluk last moment on this topic. In order to not mislead you, I will clarify the purpose of the switch PD com (not PC com) on FNB48 and many other testers. This switch related to USB Type-C Power Delivery protocol and just connects (or not) USB CC lines to onboard PD controller IC to activate PD PSUs (which turns off their output if no any device is detected). If you set this switch to off position CC lines well be directly connected from USB-C in to USB-C out to allow connected device (e.g. phone or notebook) full control to PD protocol, otherwise PD protocol can be totally controlled by tester itself (what may confuse some PD consumers). This switch not have any relation to communications between tester and PC via USB HID interface.

yildirayk commented 1 year ago

That was a big mistake, sorry guys. Now I can list the device :

Bus 001 Device 033: ID 2e3c:5558 FNIRSI FNB-58

On @didim99 's branch, it worked. On @baryluk 's branch, I couldn't make it work.

When works, it prints out :

timestamp sample_in_packet voltage_V current_A dp_V dn_V temp_C_ema energy_Ws capacity_As 1667774309.472 0 0.08629 0.00003 1.651 1.585 28.300 0.000000 0.000000 1667774309.482 1 0.08641 0.00005 1.652 1.585 28.300 0.000000 0.000001 1667774309.492 2 0.08641 0.00005 1.652 1.585 28.300 0.000000 0.000001 1667774309.502 3 0.08641 0.00005 1.651 1.584 28.300 0.000000 0.000002 1667774309.512 0 0.08641 0.00005 1.648 1.582 28.300 0.000000 0.000002 1667774309.522 1 0.08641 0.00005 1.643 1.580 28.300 0.000000 0.000003 ... 1667774326.512 0 5.25254 0.00016 0.036 0.648 28.400 0.002930 0.001019 1667774326.522 1 5.25254 0.00016 0.036 0.650 28.400 0.002938 0.001020 1667774326.532 2 5.25254 0.00016 0.036 0.650 28.400 0.002946 0.001022 1667774326.542 3 5.25254 0.00016 0.036 0.651 28.400 0.002955 0.001024 1667774326.552 0 5.25254 0.00016 0.036 0.651 28.400 0.002963 0.001025 1667774326.562 1 5.25254 0.00016 0.036 0.651 28.400 0.002972 0.001027

So sometimes it detects USB potential as 5V, sometimes not.

For gnuplot which I will try next, did you mean

sudo apt install gnuplot-x11

in Data Analysis in README @baryluk ?

Have you successfully run ./plot.gnuplot @didim99 ?

baryluk commented 1 year ago

@yildirayk Yes, should be sudo apt install gnuplot-x11 . Will fix README in a moment.

baryluk commented 1 year ago

@yildirayk Fixed README. I also added some examples of how to run it in README in https://github.com/baryluk/fnirsi-usb-power-data-logger#data-analysis

I hope that helps. Otherwise feel free to open a separate issue.

baryluk commented 1 year ago

@didim99 Thanks for the explanation about PD switch.

And of course for the PRs to add FNB58.

parkerlreed commented 1 year ago

Just a quick question for anybody with the 58 model. The latest firmware download on their website has a password. Does anybody know what that might be?

didim99 commented 1 year ago

@parkerlreed it is not a password but just captcha (and some broken logic on website frontend). Workaround: go to captcha page, open a dev tools window in your browser (typically Ctrl+Shift+I or F12) and go to Network tab. Then enter a captcha and press OK. In dev tools you can see one new POST XHR request, wait until it's status reach 200, click on the request and go to Response tab in second dev tools window (right or below). Response body contains success flag and direct download URL with security codes. Copy it (RMB -> Copy value), paste into browser's URL field and press Enter. Done.

parkerlreed commented 1 year ago

@didim99 thanks! Am I supposed to see an image? Literally all it shows is a password field saying it's encrypted.

Screenshot_20230114-134018_Chrome

parkerlreed commented 1 year ago

Oh will you look at that they give you a different page going to it on desktop... So it was literally just because I was trying to browse to it from my phone causing the confusion.

Thank you.

parkerlreed commented 1 year ago

Turns out the captcha just worked for me right away and redirected immediately going to it on the computer.