Bongofish
November 16, 2018, 09:56:39 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: You can attach photos hosted by the forum rather than using an external image hosting site, this means they will stay forever and not disappear after a year or two.
 
   Home   Help Search Login Register  
Pages: 1 2 [3] 4 5 ... 8
  Print  
Author Topic: Some technical information on ADB tablets.  (Read 66837 times)
AmbiDextrose
Full Member
***
Posts: 74


View Profile
« Reply #30 on: October 28, 2010, 06:31:57 AM »

You can actually find the format of Protocol 4 packets in:

- the WACOM Programming Guide (i.e., WACOM_progman.pdf - you should already have this)
- wcmSerial.c under the serialParseProtocol4Common() and serialParseProtocol4() function for the LINUX WACOM driver
- wacom_wac.c under the wacom_graphire_irq() functions for the LINUX WACOM driver

Looking at isdv4Parse() in wcmISDV4.c is also a good way of learning about how these protocol packets are assembled.

In any case, I think the problem I'm describing is below your USB layer - when you assemble the serial bits (from the tabet) into Bytes before sending it up to the USB layer. Could this be as simple as the bit order being reversed?
« Last Edit: October 28, 2010, 06:34:12 AM by AmbiDextrose » Logged
bernard
Administrator
Hero Member
*****
Posts: 2590


pato mania


View Profile
« Reply #31 on: October 28, 2010, 03:42:51 PM »

Maybe that protocol you are talking about is the "serial" one and not the "USB" one?
Logged
AmbiDextrose
Full Member
***
Posts: 74


View Profile
« Reply #32 on: October 28, 2010, 05:03:42 PM »

It's the same. It's just easier to understand when you're looking at the code that handles serial communications. Besides, the protocol is "Protocol 4"- USB or Serial is just the transport. There a big difference between the two.
Logged
bernard
Administrator
Hero Member
*****
Posts: 2590


pato mania


View Profile
« Reply #33 on: October 28, 2010, 06:58:59 PM »

Quote
when you assemble the serial bits (from the tabet) into Bytes before sending it up to the USB layer.
Just to clarify what is happening here: I do not "assemble serial bits" just yet.  I am strictly dumping packets coming from my genuine Wacom Graphire3. That's all. No special hardware involved in that test.

thanks for the pointers at the docs and source code.  I'll look into it.

Quote
Could this be as simple as the bit order being reversed?
Of all the bytes I see, all 8 bits goes to 1 somewhere in the middle of the packet.  I have a 0xFF number showing up for instance (full pressure).
Logged
bernard
Administrator
Hero Member
*****
Posts: 2590


pato mania


View Profile
« Reply #34 on: October 30, 2010, 03:18:31 AM »

To be able to connect my serial boards directly to my laptop (to study them for this project), I ordered [and just received] a FTDI "naked" board that also contain the RS232 level driver on it.  They sell a [tiny!] board that looks like a USB key but without any casing (it is meant to be inside a USB connector).  There are six pads to solder the signals -- GND, Tx, Rx, RTS, CTS and a power supply pin (VOUT).  The power can be reconfigured to supply 5v or 3.3v (defaults to "none").  Since this is a FTDI chip, many options are available that can be configured in the chip (for example, to configure how much mA is required from the USB port).

This was ordered from "Mouser" -- which seems to be a nice supplier for electronic parts.  Model is USB-RS232-PCBA


* rs232_usb.jpg (94.53 KB. 665x684 - viewed 504 times.)

board with its tiny box Smiley

Logged
AmbiDextrose
Full Member
***
Posts: 74


View Profile
« Reply #35 on: October 30, 2010, 04:13:05 AM »

Bernard,

I downloaded a trial version of USBlyzer and was able to decode the packets originating from a friend's Graphire3 (same tablet as yours). The 8-byte packet should be formatted in the following manner:


       b7   b6   b5   b4   b3   b2   b1   b0
B0      0    0    0    0    0    0    1    0   - WACOM Penabled indicator. Needs to be present.
B1     PROX ERA  STYL RES  RES  BTN1 BTN0 TOUC - proximity, tool type, button type
B2     X15  X14  X13  X12  X11  X10  X09  X08  - X-coordinates (MSB)
B3     X07  X06  X05  X04  X03  X02  X01  X00  - X-coordinates (LSB)
B4     Y15  Y14  Y13  Y12  Y11  Y10  Y09  Y08  - Y-coordinates (MSB)
B5     Y07  Y06  Y05  Y04  Y03  Y02  Y01  Y00  - Y-coordinates (LSB)
B6     P07  P06  P05  P04  P03  P02  P01  P00  - pressure
B7      0    0    0    0    0    0    0   P08  - pressure


My friend needed the tablet so I wasn't able to do more testing. So, seeing that you have a Graphire tablet, could you please perform the following tests while recording the USB data originating from the tablet:

  • hover stylus at top left corner
  • hover stylus at top right corner
  • hover stylus at bottom right corner
  • hover stylus at bottom left corner
  • click stylus tip at top left corner
  • click side-switch at top right corner (do not use the stylus tip)
  • click 2nd side-switch at bottom right corner (do not use the stylus tip)
  • click the eraser at the bottom left corner
  • click the stylus tip and side-switch at the top left corner
  • click the stylus tip and 2nd side-switch at the top right corner

Please make sure to move the stylus out of range (proximity) from the digitizer when going to each corner so we don't register a lot of data. Let me know if this is possible. Since I have an Intuos3, I'll attempt to decode it's packet format as well. Maybe we can ask the other members who have the following tablet types:

  • Graphire4
  • Bamboo (original)
  • Bamboo Pen (new)
  • Bamboo Pen w/ Touch (new)
  • Intuos4

I'd recommend using USBlyzer because it can also record USB PnP/insertion traffic between the WACOM digitizer and the PC. This is information we'll need if we're going to emulate one of the tablet types listed above.
« Last Edit: October 30, 2010, 04:24:24 AM by AmbiDextrose » Logged
bernard
Administrator
Hero Member
*****
Posts: 2590


pato mania


View Profile
« Reply #36 on: October 30, 2010, 09:58:25 AM »

I currently have "USB Monitor from HHD" == price is 144$US -- but only 8 days left in trial -- I am not sure how far in the PnP it goes. I am thinking I might not need that part since the Atmel chip is already taking care of the nitty-gritty details of PnP. I just enter the descriptors internally and it appears to work "magically" at that level. If my assumptions are correct (which is yet to be verified), I could be very close to actually have something working with the Teensy!

Decoding or generating that 8 byte packet is one thing and appears to be quite easy to do so, but I was also wondering what are the other packets?  Is there any to configure the tablet (going in the other direction for instance?). What happens if I modify the pressure sensitivity in the software? Does it change anything in the tablet or is it purely post-processing?

Like I already mentioned, this is a typical (8 byte) packet that I am getting: 
02 91 AF 22 AF 20 FF 01

I wanted to read on HID specification -- my little finger tells me that first byte (0x02) is part of the *HID* layer standard (which would explain why I am getting the last 7 bytes when looking at an "HID view" in my trace tool and also when using HID APIs which are much easier to code than accessing raw USB packets).

So according to your little B/b table my packet would be decoded as:

Code:
            b7   b6   b5   b4   b3   b2   b1   b0
02   B0     0    0    0    0    0    0    1    0   - WACOM Penabled indicator. Needs to be present.
91   B1     PROX ERA  STYL RES  RES  BTN1 BTN0 TOUC - proximity, tool type, button type
AF   B2     X15  X14  X13  X12  X11  X10  X09  X08  - X-coordinates (MSB)
22   B3     X07  X06  X05  X04  X03  X02  X01  X00  - X-coordinates (LSB)
AF   B4     Y15  Y14  Y13  Y12  Y11  Y10  Y09  Y08  - Y-coordinates (MSB)
20   B5     Y07  Y06  Y05  Y04  Y03  Y02  Y01  Y00  - Y-coordinates (LSB)
FF   B6     P07  P06  P05  P04  P03  P02  P01  P00  - pressure     
01   B7      0    0    0    0    0    0    0   P08  - pressure   

byte 0 is also 0x02 = my assumption here is this indicator might actually be a standard HID report control code and/or its HID report number(??) -- have to read the HID spec to confirm.
PROX = 1
ERA = 0
STYL = 0
RES = 2  (what is that?)
BTN1 = 0
BTN0 = 0
TOUC = 1   <-- is this "touch" as in "finger touch"--like the Bamboo or just means "pen touching tablet"?
X = 0xAF22  <-- did you reverse MSB/LSB ??  I think this is 0x22AF
Y = 0xAF20   <-- did you reverse MSB/LSB ??  I think this is 0x20AF
pressure = 0x1FF  <-- if B6 would be LSB and B7 MSB(bit) and pressure would be encoded on 9 bits (or 512 levels)

Can you check that this would be the correct interpretation?  How did the raw packet data looked on the Graphire3 -- you said you were able to decode it, do you still have a sample of one of the packet?

Note about the Wacom model list: what this project is about is emulating the serial and ADB wacom boards.  I need to pick existing USB tablets that has the closest technical match. Probably a Intuos4 is overkill (in terms of pressure and X/Y resolution for example). I mean, I do not need to support generating Intuos4-like packets since there is no such thing as a "serial Intuos4". Emulating a USB Intuos 1 might be enough for my purpose.  I have a serial intuos2 AND USB intuos2 coming my way in the mail right now. If they work fine, I might pick that one since I will not have a USB Intuos1 to test with.
« Last Edit: October 30, 2010, 11:04:07 AM by bernard » Logged
bernard
Administrator
Hero Member
*****
Posts: 2590


pato mania


View Profile
« Reply #37 on: October 30, 2010, 10:45:17 AM »

To get absolute corner measurements, I simply approach/slide the pen towards a corner -- so I really get the maximum coordinates. I cleared the packet dump and picked the first packet that was sent. Here are the packets you asked for (plus a few more):
Code:
Graphire3 (CTE-630 6x8):
hovering top left:        02 80 00 00 00 00 00 00
hovering top right:       02 80 40 41 00 00 00 00
hovering bot right:       02 80 40 41 20 2f 00 00
hovering bot left:        02 82 00 00 20 2f 00 00
stylus at top left:       02 81 00 00 00 00 ff 01 (max pressure)
stylus at top left:       02 81 00 00 00 00 51 01 (normal pressure)
stylus at top left:       02 80 00 00 00 00 25 00 (very light pressure)
sideswitch1 at top right: 02 82 40 41 00 00 00 00 (switch is the one closer to stylus)
sideswitch2 at bot right: 02 84 40 41 20 2f 00 00 (switch is the one "closer" to the eraser)
eraser at bot left:       02 a0 00 00 00 2f 00 00 (eraser not touching the tablet)
eraser at bot left:       02 a5 00 00 20 2f ff 01 (eraser at max pressure)
eraser at bot left:       02 a1 00 00 20 2f fe 00 (eraser at normal pressure)
eraser at bot left:       02 a1 00 00 20 2f 13 00 (eraser at very light pressure)
stylus+switch1 @top left: 02 83 00 00 00 00 ff 01 (max pressure)
stylus+switch2 @top right:02 85 40 41 00 00 ff 01 (max pressure)

To validate the MSB/LSB for coordinates:
Here are packets hovering moving from top left towards the center:
02 80 00 00 00 00 00 00
02 80 00 00 00 00 00 00
02 80 00 00 00 00 00 00
02 80 00 00 00 00 00 00
02 80 00 00 30 00 00 00
02 80 00 00 77 00 00 00
02 80 00 00 bd 00 00 00
02 80 00 00 fc 00 00 00
02 90 32 00 3b 01 00 00
02 90 92 00 7a 01 00 00
02 90 eb 00 bb 01 00 00
02 90 46 01 fe 01 00 00
02 90 9e 01 44 02 00 00
02 90 f1 01 8b 02 00 00
02 90 42 02 d6 02 00 00
02 90 9b 02 23 03 00 00
02 90 f7 02 79 03 00 00
02 90 63 03 dc 03 00 00
02 90 e7 03 33 04 00 00
02 90 4c 04 8a 04 00 00
02 90 b1 04 e0 04 00 00
02 90 16 05 37 05 00 00
02 90 7b 05 92 05 00 00
02 90 e5 05 f5 05 00 00
02 90 50 06 53 06 00 00
02 90 be 06 b3 06 00 00


Notes:
- I think the MSB/LSB are reversed in the X/Y coordinates in your table
- the eraser is not just a on/off switch but has the full pressure sensitivity.
- What is that "RES" bit for going from 0 to 1 in the last stream of packets? It went one as soon as the X coordinates was non-zero (was still zero even if the Y coordinate was non-zero). It might mean  that "pen is within the active area"?.
- according to the ADB analysis of Tufty (first post in this thread), the eraser + buttons might be encoded specially (some combinations are not supported since the eraser was re-using bits I am not sure which). I did not do further tests on that regard. This might be only a ADB protocol thing also.
- I realized (afterwards) that my tablet controls my mouse in "relative" mode (mouse mode) -- but it does not seem to affect the packets since I do see absolute numbers in there -- there's nothing relative when I see the number change.
« Last Edit: October 30, 2010, 11:03:08 AM by bernard » Logged
AmbiDextrose
Full Member
***
Posts: 74


View Profile
« Reply #38 on: October 30, 2010, 11:37:28 AM »

Yeah, I think you're right about the Byte ordering - I checked the Linux driver code and it does look like WACOM is using little endian for the coordinates and the pressure. And RES means reserved- hat's another way of saying "WTH does this bit do?"
« Last Edit: October 30, 2010, 11:41:03 AM by AmbiDextrose » Logged
Drewid
Administrator
Hero Member
*****
Posts: 2289


wielder of electric crayons


View Profile
« Reply #39 on: October 30, 2010, 12:00:39 PM »

Does that protocol handle multiple pens? Just wondering about the RES value.
Logged

Games work site:  Drewnorthcott.co.uk
Personal site: Bongofish.co.uk
valoruzan
New Poster
*
Posts: 31


View Profile
« Reply #40 on: October 30, 2010, 01:36:26 PM »

Hi Bernard,
Here is the Intuos3 A3 (wide) descriptor.

Code:
Device Descriptor:
bcdUSB:             0x0110
bDeviceClass:         0x00
bDeviceSubClass:      0x00
bDeviceProtocol:      0x00
bMaxPacketSize0:      0x08 (8)
idVendor:           0x056A (WACOM Co., Ltd.)
idProduct:          0x00B4
bcdDevice:          0x0105
iManufacturer:        0x01
0x0409: "Tablet"
iProduct:             0x02
0x0409: "PTZ-1231W"
iSerialNumber:        0x00
bNumConfigurations:   0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:     Full
Device Address:       0x01
Open Pipes:              1

Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x000A (10)
bInterval:            0x04

Configuration Descriptor:
wTotalLength:       0x0022
bNumInterfaces:       0x01
bConfigurationValue:  0x01
iConfiguration:       0x00
bmAttributes:         0x80 (Bus Powered )
MaxPower:             0x96 (300 Ma)

Interface Descriptor:
bInterfaceNumber:     0x00
bAlternateSetting:    0x00
bNumEndpoints:        0x01
bInterfaceClass:      0x03 (HID)
bInterfaceSubClass:   0x01
bInterfaceProtocol:   0x02
iInterface:           0x00

HID Descriptor:
bcdHID:             0x0100
bCountryCode:         0x00
bNumDescriptors:      0x01
bDescriptorType:      0x22
wDescriptorLength:  0x00AA

Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x000A (10)
bInterval:            0x04


Intuos2 A5 data coming on Monday.

I hope that helps,
Val
Logged
AmbiDextrose
Full Member
***
Posts: 74


View Profile
« Reply #41 on: October 31, 2010, 12:19:04 AM »

Does that protocol handle multiple pens? Just wondering about the RES value.

Not the Graphire. To my knowledge, the Graphire only supports one type of pen. it does support (WACOM) mice but this has a different packet format.
Logged
bernard
Administrator
Hero Member
*****
Posts: 2590


pato mania


View Profile
« Reply #42 on: October 31, 2010, 02:33:45 PM »

How do we know what is the maximum X/Y value?  My Graphire3 appears to return me these ranges:
Code:
X :   0  ...   0x4140  (16704)
Y :   0  ...   0x2f20  (12064)

The Linux driver code has the following entry for the Graphire3: (device id: 0x14)

 static const struct wacom_features wacom_features_0x14 =
   { "Wacom Graphire3 6x8",  WACOM_PKGLEN_GRAPHIRE,  16704, 12064,  511, 63, GRAPHIRE };

So an important point here is that the maximum number seems hardcoded in the driver. Here are some of the related definition:

#define WACOM_PKGLEN_PENPRTN    7
#define WACOM_PKGLEN_GRAPHIRE    8
#define WACOM_PKGLEN_BBFUN    9
#define WACOM_PKGLEN_INTUOS   10
#define WACOM_PKGLEN_TPC1FG    5
#define WACOM_PKGLEN_TPC2FG   14
#define WACOM_PKGLEN_BBTOUCH   20

struct wacom_features {
   const char *name;
   int pktlen;
   int x_max;
   int y_max;
   int pressure_max;
   int distance_max;
   int type;

   int device_type;
   int x_phy;
   int y_phy;
   unsigned char unit;
   unsigned char unitExpo;
};

This initialization does not fill all the fields it seems. What is that "distance max" thingy?  It is set to 63 for the Graphire3.
Logged
Drewid
Administrator
Hero Member
*****
Posts: 2289


wielder of electric crayons


View Profile
« Reply #43 on: October 31, 2010, 02:51:16 PM »

Read height threshold? I know that's adjustable in earlier models.
Logged

Games work site:  Drewnorthcott.co.uk
Personal site: Bongofish.co.uk
AmbiDextrose
Full Member
***
Posts: 74


View Profile
« Reply #44 on: October 31, 2010, 05:32:13 PM »

The distance field only applies to Intuos, Cintiq, Graphire 4s or the Bamboo. The older stuff didn't report this field, at least according to wacom_wac.c.
Logged
Pages: 1 2 [3] 4 5 ... 8
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!