Announcement

Collapse
No announcement yet.

A $14 USB Thermometer That Works Well With Linux

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

  • #21
    Anyone have luck compiling this? I get the following on my RHEL 7.2 workstation:

    Code:
    [FONT=courier new]$ gcc ./temperv14.c 
    /tmp/ccXfTjto.o: In function `usb_detach':
    temperv14.c:(.text+0x50): undefined reference to `usb_detach_kernel_driver_np'
    /tmp/ccXfTjto.o: In function `setup_libusb_access':
    temperv14.c:(.text+0xf1): undefined reference to `usb_set_debug'
    temperv14.c:(.text+0xfd): undefined reference to `usb_set_debug'
    temperv14.c:(.text+0x102): undefined reference to `usb_init'
    temperv14.c:(.text+0x107): undefined reference to `usb_find_busses'
    temperv14.c:(.text+0x10c): undefined reference to `usb_find_devices'
    temperv14.c:(.text+0x168): undefined reference to `usb_set_configuration'
    temperv14.c:(.text+0x18e): undefined reference to `usb_claim_interface'
    temperv14.c:(.text+0x1b4): undefined reference to `usb_claim_interface'
    /tmp/ccXfTjto.o: In function `find_lvr_winusb':
    temperv14.c:(.text+0x1de): undefined reference to `usb_busses'
    temperv14.c:(.text+0x249): undefined reference to `usb_open'
    /tmp/ccXfTjto.o: In function `ini_control_transfer':
    temperv14.c:(.text+0x2ea): undefined reference to `usb_control_msg'
    /tmp/ccXfTjto.o: In function `control_transfer':
    temperv14.c:(.text+0x426): undefined reference to `usb_control_msg'
    /tmp/ccXfTjto.o: In function `interrupt_transfer':
    temperv14.c:(.text+0x5c0): undefined reference to `usb_interrupt_write'
    temperv14.c:(.text+0x5ff): undefined reference to `usb_interrupt_read'
    temperv14.c:(.text+0x683): undefined reference to `usb_release_interface'
    /tmp/ccXfTjto.o: In function `interrupt_read':
    temperv14.c:(.text+0x73f): undefined reference to `usb_interrupt_read'
    /tmp/ccXfTjto.o: In function `interrupt_read_temperatura':
    temperv14.c:(.text+0x86c): undefined reference to `usb_interrupt_read'
    /tmp/ccXfTjto.o: In function `bulk_transfer':
    temperv14.c:(.text+0x9be): undefined reference to `usb_bulk_write'
    temperv14.c:(.text+0x9fd): undefined reference to `usb_bulk_read'
    temperv14.c:(.text+0xa74): undefined reference to `usb_release_interface'
    /tmp/ccXfTjto.o: In function `main':
    temperv14.c:(.text+0xfb2): undefined reference to `usb_release_interface'
    temperv14.c:(.text+0xfc3): undefined reference to `usb_release_interface'
    temperv14.c:(.text+0xfcf): undefined reference to `usb_reset'
    collect2: error: ld returned 1 exit status[/FONT]

    Comment


    • #22
      Ok, I figured it out. First modify the code to perform usb_reset() instead of usb_close() as suggested by Michael:

      Code:
      [FONT=courier new]sed -i s/usb_close/usb_reset/g temperv14.c[/FONT]
      Then compile it like so:

      Code:
      [FONT=courier new]gcc -DUNIT_TEST -o temperv14 temperv14.c -lusb[/FONT]
      I'm running RHEL 7.2, and I had to install the usb development package before it would compile:

      Code:
      [FONT=courier new]sudo yum install libusb-devel[/FONT]
      Now it works great. Note that I had to run it using sudo in order to access the usb device:

      Code:
      [FONT=courier new]$ sudo ./temperv14 
      2016/05/24 18:43:18 Temperature 73.85F 23.25C[/FONT]

      Comment


      • #23
        Originally posted by torsionbar28 View Post
        Now it works great. Note that I had to run it using sudo in order to access the usb device:
        Here's what I put in a file in /etc/udev/rules.d/ to solve that for my $50 Chinese receipt printer (don't underestimate how useful they are once you have one).

        Code:
        SUBSYSTEMS=="usb", ATTRS{idVendor}=="0416", ATTRS{idProduct}=="5011", MODE:="0666"
        It should be pretty obvious how to adapt it. (I can also show you other udev tricks if you have a use for them, like amending a USB-NES controller adapter's HID descriptor so SDL2 recognizes it as a joystick or running a script whenever the device is initialized (boot or hotplug))

        Comment


        • #24
          Amazon comments aren't encouraging. Inaccurate and self heats. And expensive in the bargain.

          I'll go buy one of these old mercury thermometers in a brick and mortar store.

          Comment

          Working...
          X