USB detection for CASIO calculators¶
When looking for CASIO calculators, the following vendor and product identifiers (VID/PID) can be used:
|
|
|
|
|
|
Description |
---|---|---|---|---|---|---|
|
|
|
|
|
|
Classpad 300 / 330 (+), fx-9860G Slim |
|
|
|
|
|
|
Graph 35+/75/85/95 |
|
|
|
|
|
|
Classpad 330+, fx-CG20, fx-CP400, fx-CP400+E |
|
|
|
|
|
|
fx-CG50, Graph 90+E, fx-9750GIII (>= OS 3.8) |
The interface class 255
is used when the device presents CASIOLINK,
Protocol 7.00 or Protocol 7.00 Screenstreaming directly over bulk transfers,
while the interface class 8
is used in “USB key” mode, i.e.
when the file system and main memory are presented using USB Mass Storage.
Warning
While more modern devices speaking Protocol 7.00 / Protocol 7.00
Screenstreaming over bulk transfers use a specific iManufacturer
and a greater bcdUSB
, ancient Protocol 7.00 / Protocol 7.00
Screenstreaming devices, such as the fx-9860G Slim, are indistinguishable
from Classpad 300 / 330 (+) devices on USB alone.
Because of this, in the cahute_open_usb_link()
and
cahute_open_simple_usb_link()
interfaces, the protocol can either
be forced by the caller using the CAHUTE_USB_CAS300
or
CAHUTE_USB_SEVEN
flag, or determined once the link is made
using automatic protocol detection.
Warning
Some older fx-9860G derivatives using OS 1.x require a specific USB control transfer to be run before Protocol 7.00 can be used; see Initiating the link for more information.
Note
For reference, the following USB serial cables have also be encountered in the wild:
|
|
Description |
---|---|---|
|
|
SB-88 serial cable (official CASIO cable). |
|
|
Util-Pocket (defunct alternative vendor) serial cable. Uses an USB serial converter from FTDI. |
Note however that these should be used through the system’s serial bus interface rather than directly.
Vendor-specific USB device enabling¶
Over USB links, some older fx-9860G derivatives, such as the fx-9860G Slim running OS 1.x, require a special USB control flow to be executed before they can send or receive any data. This can manifest differently depending on the application protocol:
With Protocol 7.00, the calculator will not answer the initial check.
With Protocol 7.00 Screenstreaming, the calculator will freeze until the control flow is made, since it is attempting to send screen data.
This control flow has the following properties:
bmRequestType
set to0x41
, to designate a vendor-specific interface request with no incoming data transfer;bRequest
set to0x01
, as it is the command that enables Protocol 7.00 data transfers.Both
wValue
andwIndex
set to0x0000
.No data transfer.
Using libusb, this can be done using the following excerpt:
libusb_control_transfer(
device_handle,
0x41, /* bmRequestType */
0x01, /* bRequest */
0x0000, /* wValue */
0x0000, /* wIndex */
NULL,
0,
300
);
Ideally, this flow is run by a driver that can be used as soon as the calculator is connected to the host. Otherwise, it means that the calculator may freeze until a transfer utility is used, such as one of Cahute’s command-line utilities.
Driver detection on Microsoft Windows¶
Any user program using the Windows API (Win32) requires a kernel driver to communicate with the calculator through USB. This kernel driver can be one of:
CASIO’s CESG502 driver, which supports both bulk transport (fx-9860G) and transport using proprietary UMS commands (fx-CP, fx-CG).
A libusb-compatible kernel driver, including WinUSB.
CESG502 is distributed with FA-124, and is necessary for CASIO’s software to successfully detect and communicate calculators connected using USB. This means it is necessary for any user program that co-exists with it to work with CASIO’s driver.
It can be detected using libusb, but cannot be opened using the same tool;
one must use detection with SetupAPI or cfgmgr32, check that the device
driver is CESG502, and if it’s the case, open and use the device using
fileapi (CreateFile
, ReadFile
, WriteFile
, CloseFile
).
Note
It is possible to access device instance properties on Windows OSes before Vista, e.g. Windows XP; see Accessing Device Instance Properties (Prior to Windows Vista) for more information.
It uses {36fc9e60-c465-11cf-8056-444553540000}
, the same GUID as
generic USB devices, which is normally forbidden for Independent
Hardware Vendors (IHV) such as CASIO, so this key cannot be used to
uniquely identify the driver.
Cahute currently matches the service (CM_DRP_SERVICE
) to PVUSB
,
since this is the value encountered in the wild.