Node - Node-HID not finding device - node.js

I am trying to create an Angular and Node program that utilizes a barcode scanner. I am building on a mac and I am using a Motorola DS9208 scanner which can read both qr codes and barcodes. When I console.log(devices) all of the devices are made by Apple except this one, which does not provide much information:
{
vendorId: 0,
productId: 0,
path: 'IOService:/AppleACPIPlatformExpert/PCI0#0/AppleACPIPCI/SBUS#1F,3/AppleSMBusPCI/BUS0#0/AppleSMBusControllerICH/MKY0/AppleMikeyDriver/AppleMikeyHIDDriver',
serialNumber: '',
manufacturer: '',
product: 'Apple Mikey HID Driver',
release: 0,
interface: -1,
usagePage: 12,
usage: 1
}
It is the only USB device plugged in so I assume that it is the HID it is referring to. However, My problem is when I try to actually scan things. When I set var device = new HID.HID(0,0) since the vendor and product IDs are 0, and use function
device.on('data', function(data) { console.log(data)} )
nothing happens. Same when I do the same for checking errors. When the scanner scans any barcode it beeps once then beeps four more times with red lights giving off some sort of error message. Can anyone help me out? Thank you

Related

Can a single acpi driver work for two devices where one is normal device and another is platform device

I want to understand if it is possible to have a single driver shared between following two devices. E.g. from the ACPI tables, the two devices are mapped as follows:
Scope (\_SB)
{
Device (XYZ)
{
Name (_HID, "XYZ123") // _HID: Hardware ID
Name (_UID, "XYZ") // _UID: Unique ID
Method (_DIS, 0, NotSerialized) // _DIS: Disable Device
{
}
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
{
}
...
}
}
Scope (\_SB.PCI0.PEG0.ABC)
{
OperationRegion (PCIM, SystemMemory,)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
{
...
}
}
IIUC, device XYZ is platform device and device ABC is discoverable PCI device.
I need to access _DSM method of Device (XYZ) using the ACPI driver of device ABC (_SB.PCI0.PEG0.ABC). From https://lwn.net/Articles/367630/ I understand that in order to write ACPI driver for a device we need to have following
static const struct acpi_device_id bt_device_ids[] = {
{ "TOS6205", 0},
{ "", 0},
};
MODULE_DEVICE_TABLE(acpi, bt_device_ids);
static struct acpi_driver toshiba_bt_driver = {
.name = "Toshiba BT",
.class = "Toshiba",
.ids = bt_device_ids,
.ops = {
.add = toshiba_bt_rfkill_add,
.remove = toshiba_bt_rfkill_remove,
},
.owner = THIS_MODULE,
};
I was wondering if adding a new additional entry in 'acpi_device_id' will help with the same 'acpi_driver'. Also why we add an extra null entry { "", 0} for 'acpi_device_id'? I understand that each device has to register itself with ACPI and also register for notifiers to receive any notifications from ACPI, I found https://www.kernel.org/doc/Documentation/acpi/enumeration.txt but I could not understand it completely. Is there a way that already existing driver for device ABC can be modified to access _DSM() functions of XYZ device?

Which HID key code to use for KEYCODE_BACK button mapping?

Platform:
STB Xiaomi Mi Box S 4
OS Version:
Android Version 9
Issue description:
I want to use the USB keyboard gadget to control the box. I mapped the remote controller buttons (arrow buttons/select/home) into corresponding HID key codes following the page. However, none of the specified/corresponding key codes (0x00f1, 0x009e) for the KEYCODE_BACK button is working as expected.
Question:
Do you maybe know which HID key code should be used for the BACK button?
Appreciated any help!
I found detailed document about HID usages. I hope you can find your answer from the pdf.
PDF: https://usb.org/sites/default/files/hut1_21.pdf
You may use the following code to determine if the Key is Back / Menu on the Android device / key code
if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_MENU || event.getKeyCode() == KeyEvent.KEYCODE_BUTTON_MODE) && event.getRepeatCount() == 0) {
if( onBackPressed() ) { // function to determine if we should block the action in your code and do something else return true if you want to proc
return true;
} else {
// let the Android system handle the back button
return false;
}
}

After taking Picture, how to select Ok in appium when tick mark cant be located?

After taking Picture, how to select Ok in appium when tick mark cant be located?
only camara layout is Higlighted and i am not able to loacte tick mark or revert.
Please try below code snippet. If you are able to click using android keyboard then below code should work.
((AndroidDriver)driver).pressKey(new KeyEvent(AndroidKey.SEARCH));
I acheived this using TouchAction.
TouchAction touchAction = new TouchAction(driver);
touchAction.tap(new PointOption().withCoordinates(111, 222)).perform()
solution for accepting image using camera app in appium.
keyEvent=>27, is use to capture the image using camera app.
i used below code to accept the captured image. (but its not working)
i used keyEvent=> 66, Enter button to accept the image (but its not working).
i used keyEvent=> 84, Space button to accept the image (but its not working).
below working code.
i used keyEvent=> 22 and then i used keyEvent=> 66, it will accept the image.
$app.press_keycode(27) #click on camera accept button.
$app.press_keycode(22)
$app.press_keycode(66)
sleep 2
$app.press_keycode(27)
$app.press_keycode(22)
$app.press_keycode(66)
Note: repeat the code for 2 twice
i used keyEvent=> 21 and then i used keyEvent=> 66 and i used keyEvent=> 27, it will allow u to retake the image.
i used keyEvent=>4, it will take back u form camera app
The way I handled Camera and Tick button initially was using Android Key Codes:
Thread.sleep(2000);
androidDriver.pressKey(new KeyEvent(AndroidKey.CAMERA));
Thread.sleep(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
Thread.sleep(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
Thread.sleep(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.ENTER));
In most of the devices which I researched earlier, the above snippet worked like a charm for me. However, when I started testing on Android versions 9, 10 and 11 recently, this wasn't working and the number of tabs increased to 3 or 4. To handle this in most of the devices like Samsung, OnePlus, Google Pixel, I refactored the code as:
Thread.sleep(2000);
// Click Camera shutter button
androidDriver.pressKey(new KeyEvent(AndroidKey.CAMERA));
try {
WebDriverWait wait = new WebDriverWait(androidDriver, 10);
wait.until(ExpectedConditions.elementToBeClickable((MobileBy.AccessibilityId("Done");
// Click Done or Tick after clicking photo (Mostly visible in OnePlus, Nokia, Google Pixel devices)
androidDriver.findElementByAccessibilityId("Done").click();
} catch (NoSuchElementException e) {
flag = true;
System.out.println("NoSuchElement for DONE Button");
}
if (flag) {
try {
// Click OK after clicking photo (Mostly visible in Samsung devices)
// No need to put WebDriverWait here as we already waited for 10 secs after clicking on Camera
androidDriver.findElementByXPath("//android.widget.TextView[#text='OK']").click();
flag = false;
System.out.println("OK Button Clicked");
} catch (NoSuchElementException e) {
flag = true;
System.out.println("NoSuchElement for OK Button");
}
}
if (flag) {
// If both above methods failed, then this may work (Mostly works for Xiaomi, Nokia devices)
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
hardStopWait(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
hardStopWait(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.ENTER));
System.out.println("TABS & ENTER Pressed");
}

How to determine OS type on device with Tabris

I've looked through the official documentation on the Tabris site, but I've not yet found an answer. So, within a Tabris app, how does one determine the current OS its running within?
Specifically, I'd like to be able to detect Android or iOS.
Edit
I found this example on their site after #Holger posted the answer, I'm pasting here to help others:
var page = tabris.create("Page", {
title: "Device Info",
topLevel: true
});
["platform", "version", "model", "language"].forEach(function(property) {
tabris.create("TextView", {
layoutData: {left: 10, right: 10, top: [page.children().last(), 10]},
text: property + ": " + device[property]
}).appendTo(page);
});
page.open();
There is a Client Service called "ClientDevice". You can ge tthe platform, os version and so on form it. See http://developer.eclipsesource.com/tabris/docs/1.4/working/client-services/client-device#the_clients_platform

How to write on InkPresenter in Silverlight For Windows Embeddeded?

I want to make a doodle sort of control on an embedded device and this is what I’ve done so far:
Placed an InkPresenter control (Home_Ink) and these are its events:
Home_Ink_MouseLeftButtonDown:
m_pHome_Ink->CaptureMouse(retValue);
pApplication->CreateObject(&s);
pApplication->CreateObject(&pStylusPoints);
pApplication->CreateObject(&pDrawingAttributes);
s->SetStylusPoints(pArgs->pStylusPoints);
pDrawingAttributes->SetHeight(pencilWidth);
pDrawingAttributes->SetWidth(pencilWidth);
pDrawingAttributes->SetColor(pencilColor);
s->SetDrawingAttributes(pDrawingAttributes);
m_pHome_Ink->GetStrokes(&pStrokes);
pStrokes->Add(s,NULL);
Home_Ink_MouseLeftButtonUp :
s=NULL;
m_pHome_Ink->ReleaseMouseCapture();
Home_Ink_MouseMove :
if(s!=NULL)
{
s->SetStylusPoints(pArgs->pStylusPoints);
pStrokes->Add(s,NULL);
}
There are no build errors and the application is running.
But nothing is getting drawn on the inkpresenter. What am I doing wrong??

Resources