You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to open and read from a TRF7970A EVM board (by Texas Instruments) connected to my Mac. The device shows up in "ioreg -lfxp IOUSB" as a "USB to UART Bridge Controller" and gives the vid, pid and serial number.
The device path in my Mac is as follows (machine name redacted)
koushikdas@xxxx ~ % ls /dev/tty* | grep usb
/dev/tty.usbserial-0001
I changed the permission as follows:
sudo chmod -R 777 /dev/tty.usbserial-0001
Below is my code snippet:
int vid = (int) Long.parseLong(Integer.toHexString(0x10c4), 16);
int pid = (int) Long.parseLong(Integer.toHexString(0xea60), 16);
try {
HidApi.init();
// HidDeviceStructure hidDeviceStructure = HidApi.open("/dev/tty.usbserial-0001");
HidDeviceStructure hidDeviceStructure = HidApi.open(vid, pid, "0001");
HidApi.setNonBlocking(hidDeviceStructure, true);
log("Reading device data " + HidApi.read(hidDeviceStructure, new byte[64]));
log("Device SN " + HidApi.getSerialNumber(hidDeviceStructure));
log("Device PID " + HidApi.getProductId(hidDeviceStructure));
log("Device Manufacturer " + HidApi.getManufacturer(hidDeviceStructure));
} catch (Exception e) {
log("Not able to open Hid device");
e.printStackTrace();
}
When I run the code, I see the following in console (package name redacted):
00:22:44.918 [ForkJoinPool-1-worker-1] INFO xxx - Reading device data -2
00:22:44.918 [ForkJoinPool-1-worker-1] INFO xxx - Device SN Device not initialised
00:22:44.918 [ForkJoinPool-1-worker-1] INFO xxx - Device PID Device not initialised
00:22:44.918 [ForkJoinPool-1-worker-1] INFO xxx - Device Manufacturer Device not initialised
I also tried setting HidApi.useLibUsbVariant = true; but got the same result.
Any suggestion to resolve this would be helpful.
The text was updated successfully, but these errors were encountered:
Have you tried using the latest code in the develop branch? There have been a few updates to the hidapi library that haven't been merged into master yet.
Thanks Gary. Is there a way I can use the develop branch in my Gradle project without cloning the repo?
I tried with below 2 approaches:
//Approach 1 - JitPack in build.gradle
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
...
implementation('org.hid4java:hid4java:develop-SNAPSHOT')
...
}
//Approach 2 - Gradle plugin in settings.gradle
plugins {
id 'com.alexvasilkov.git-dependencies' version '2.0.1'
}
In both cases Gradle is not able to resolve hid4java. I tried without JitPack and with the dependency only as per https://github.com/gary-rowe/hid4java/wiki/FAQ#gradle-project but see error "Could not find org.hid4java:hid4java:develop-SNAPSHOT"
Hi Gary,
To get around the above problem of adding develop-SNAPSHOT as a dependency, I downloaded and copied the java files from src/main/java/org/hid4java to my project workspace. Also copied the darwin libraries to my project src/main/resources folder. Changed the package pointers in files accordingly. But I still see the same output (i.e read(...) returns -2 and Device not initialised for other details) when I run the program. Any suggestion?
I am trying to open and read from a TRF7970A EVM board (by Texas Instruments) connected to my Mac. The device shows up in "ioreg -lfxp IOUSB" as a "USB to UART Bridge Controller" and gives the vid, pid and serial number.
The device path in my Mac is as follows (machine name redacted)
koushikdas@xxxx ~ % ls /dev/tty* | grep usb
/dev/tty.usbserial-0001
I changed the permission as follows:
sudo chmod -R 777 /dev/tty.usbserial-0001
Below is my code snippet:
int vid = (int) Long.parseLong(Integer.toHexString(0x10c4), 16);
int pid = (int) Long.parseLong(Integer.toHexString(0xea60), 16);
try {
HidApi.init();
// HidDeviceStructure hidDeviceStructure = HidApi.open("/dev/tty.usbserial-0001");
HidDeviceStructure hidDeviceStructure = HidApi.open(vid, pid, "0001");
HidApi.setNonBlocking(hidDeviceStructure, true);
log("Reading device data " + HidApi.read(hidDeviceStructure, new byte[64]));
log("Device SN " + HidApi.getSerialNumber(hidDeviceStructure));
log("Device PID " + HidApi.getProductId(hidDeviceStructure));
log("Device Manufacturer " + HidApi.getManufacturer(hidDeviceStructure));
} catch (Exception e) {
log("Not able to open Hid device");
e.printStackTrace();
}
When I run the code, I see the following in console (package name redacted):
00:22:44.918 [ForkJoinPool-1-worker-1] INFO xxx - Reading device data -2
00:22:44.918 [ForkJoinPool-1-worker-1] INFO xxx - Device SN Device not initialised
00:22:44.918 [ForkJoinPool-1-worker-1] INFO xxx - Device PID Device not initialised
00:22:44.918 [ForkJoinPool-1-worker-1] INFO xxx - Device Manufacturer Device not initialised
I also tried setting HidApi.useLibUsbVariant = true; but got the same result.
Any suggestion to resolve this would be helpful.
The text was updated successfully, but these errors were encountered: