Commit Graph

182 Commits (643099b8583b14192f9bceee1d27220cfb0b4591)

Author SHA1 Message Date
Peter Hutterer 643099b858 Fix flake8 errors - ambiguous variable name 'l'
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-22 17:09:27 +10:00
Peter Hutterer 27164aba52 Fix flake8 errors - f-string without placeholders
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-22 17:09:27 +10:00
Taihsiang Ho (tai271828) 3c1a84e1ab protocol: rm unused class WacomPacket 2020-04-21 15:23:44 +10:00
Niclas Hoyer a0566e0dc0 Workaround for Spark register problems
This is a workaround for registering problems with Spark.
The registration hangs at "Connecting to device...".

Internally the `GENERAL_ERROR` occurs, which is expected
when registering a Spark device, but this should also
raise an AuthorizeException, but it instead reaches the
handler as DeviceError.

It is currently unclear why the `GENERAL_ERROR` passes to
this handler, so this catches any `GENERAL_ERROR` while
registering a Spark device.
2020-01-07 11:00:11 +10:00
Peter Hutterer 0e12369866 wacom: set the x/y min/max to the correct device units
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:18 +10:00
Peter Hutterer 1c893d14e8 wacom: make a debug message more informative
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:18 +10:00
Peter Hutterer 960904d481 wacom: don't fetch the dimensions if we're stopping live mode
There's just no point to that and if the tablet is currently in live mode, it
refuses the GET_WIDTH request anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:18 +10:00
Peter Hutterer e37016dc7b Fix deprecated use of @GObject.property → @GObject.Property
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-29 10:42:44 +10:00
Peter Hutterer a0fb4cf0f9 wacom: use 'with' to group request/replies together
Previously, the YAML output was basically:

  - send: [0xb9, 0x01, 0x00]
  - recv: [0xba, 0x02, 0x44, 0x00]

using a context manager where replies are expeced we can now group the
replies in the yaml file:

        with logger as _:
           self.send_nordic_command(...)
           self.wait_nordic_data(...)

And that will prodice a grouped entry in the YAML file:

  - send: [0xb9, 0x01, 0x00]
    recv: [0xba, 0x02, 0x44, 0x00]

Which means processing those becomes a bit easier.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-26 09:05:17 +10:00
Peter Hutterer 79480b867d protocol: store the interaction name in the NordicData where appropriate
This means the data logger can then access that name without needing a
separate lookup table.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-26 09:05:17 +10:00
Peter Hutterer e30787234c wacom: change the data logger to take a request msg instead of just raw data
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-26 09:05:17 +10:00
Peter Hutterer 9a21c2318a wacom: store the default point size for each tablet
It'll be overwritten by the messages anyway but for the converter tool this is
handy.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 11:31:30 +02:00
Peter Hutterer 8eea6468b7 wacom: add a session id field to make it easier to find log files
The session id is a UUID, postfixed by an incrementing number. The UUID stays
the same for Tuhi's livetime, the number increments with every bluetooth
connect/disconnect. Result is e.g. 4e55c30035d043ce9f6f4914fb223820-2.

This session id is printed to the log file, added to the YAML raw logs and to
the JSON file, making it easier which log part resulted in which drawing, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:46:14 +02:00
Peter Hutterer f21af42131 protocol: on the spark treat a general error during connect as wrong uuid
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00
Peter Hutterer 7a121cfe6c protocol: print the DeviceError as something useful
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00
Peter Hutterer 88d9cf14bd wacom: move an assignment to a shared path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00
Peter Hutterer ebf48be0ad wacom: replace the last exception with a protocol exception
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00
Peter Hutterer be38e1a781 wacom: replace one 'old' exception with the new protocol one
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00
Peter Hutterer 22673b9e5a wacom.py: drop two now-unused functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00
Peter Hutterer 77048d572d protocol: use a MisingReplyError instead of timeout exceptions
It's caused by a timeout but the underlying issue is that we never got the
reply that we wanted.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00
Peter Hutterer 4eee838d94 protocol: implement the message to wait for the end of pen data
This pushes the CRC fetching into the messages, making the caller code more
generic.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00
Peter Hutterer fc280ce555 wacom: use the DeviceError for the invalid state message
Nothing throws the previous exception anymore anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-23 10:38:36 +02:00
Peter Hutterer cdb7f905ca Store the raw logs in the specified config dir too
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 17:20:13 +10:00
Peter Hutterer bad7aa4554 wacom: treat any settings.ini misconfigurations as unregistered
This situation will never be handled correctly b a GUI and there's no need to,
our settings aren't supposed to be edited by puny humans. So just log an error
and treat the device as unregistered.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 12:53:47 +10:00
Peter Hutterer fe75fc4342 wacom: be more specific in the spark's original error code
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 10:52:30 +10:00
Peter Hutterer 354c84d750 wacom: switch two exceptions to a the protocol types
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 10:52:30 +10:00
Peter Hutterer 0b8d3773d7 wacom: drop now-unused check_ack function
And since this function was the only one generating some of the exceptions,
let's remove those too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 10:52:30 +10:00
Peter Hutterer f7f6d02a37 wacom: drop now unnecessary transaction count
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 09:59:14 +10:00
Peter Hutterer e030b0b3ea base: add an argument to peek at the first drawing only
Use --peek to download the first (oldest) drawing on the device but do not
delete it. This is primarily intended as a debugging option, so we can debug
the tablet handling without having to draw new drawings (which cause the
protocol messages to change slightly).

Since the tablet only has a "download oldest file" command this isn't very
useful to end users. If there are two or more files on the tablet, we can only
ever retrieve the oldest one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 09:59:14 +10:00
Peter Hutterer 6e4b190169 protocol: rename a few protocol messages to better reflect what they do
0xc3 is 'download the oldest file'
0xca is 'delete the oldest file' (usually the one we just received) from the tablet.
0xc1 is 'how many files are there'

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-22 09:59:14 +10:00
Peter Hutterer fa888b742f wacom: switch to the new protocol stroke parsers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer 07dba6c892 wacom: store the default orientation for each tablet
Not actually used at this point, but this way we have default
width/height/orientation etc. all in one place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer e420b04fda protocol: add stroke parsing
This is a slightly different model as the messages, primarily because it's not
quite as model-specific. So there's only one parse function and it can handle
both file types that we currently support (intuos pro and the spark/slate
bits).

All wrapped into their own classes to make future extensions a bit easier.
It's not a 1:1 implementation of the tuhi/wacom.py bits either because we now
know about a few extra bits like the flags in stroke headers.

Most importantly though, this can be easily tested now, with one test case
searching for raw logs in $XDG_DATA_HOME/tuhi/raw and parsing all of those. So
the more files are sitting in there (i.e. the more the tablet is used), the
better the test suite becomes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer 541077a65b Add a utility function module
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer 91203701cf wacom: group the list2hex output
Group by size 8 by default.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 09:31:52 +02:00
Peter Hutterer 244b4f5994 wacom: make the parents for the raw log directory too
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-21 14:04:23 +10:00
Peter Hutterer 92fcfd12cc wacom: update the dimensions with the point size
Make sure our dimensions are in actual µm.

Note that this will mess with any cached JSON files since they are now on a
different scale.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-20 12:02:30 +10:00
Peter Hutterer 6d718f16b5 wacom: rework the file data prefix handling
We know how it's supposed to look like, so let's hardcode it a bit better.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-19 15:46:50 +02:00
Peter Hutterer 116589d28d wacom: pen data first four bytes are the internal file format
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-19 15:46:50 +02:00
Peter Hutterer be6d57562a Switch to pathlib everywhere
gresources and svgwrite don't (yet?) take a Path though, so we have to use
os.fspath() to convert those.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-19 14:11:36 +10:00
Peter Hutterer 32091d9a7b wacom: improve a timestamp debug message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 15:21:24 +10:00
Peter Hutterer e5375a55dd wacom: name an argument to make it more obvious what the magic 5 means
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 15:21:24 +10:00
Peter Hutterer 790d8c5e31 wacom: fix pressure range for the IntuosPro
8191 seems to be the max value

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 15:05:49 +10:00
Peter Hutterer 85f2e3c67a wacom: fix the dimensions for the Spark
The reachable range is 2100x14800, highest pressure is 1023. Unlike the slate
the paper block still affords to address almost the whole range even though
the paper is slightly narrower than the range - but it can slide left/right by
about 5mm.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 15:05:49 +10:00
Peter Hutterer bd6278a305 wacom: change the raw log file name to include the timestamp
Because it's annoying when there's an issue with the timestamp in the file and
you have to grep for the file name.

And while we're there, change the human readable date to be actually readable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 14:58:41 +10:00
Peter Hutterer 35acce3ea6 wacom: log the raw yaml data into a subdirectory
It gets a bit too confusing otherwise with all the weirdly named files around

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 14:58:41 +10:00
Peter Hutterer 6bf7715e83 wacom: write just the timestamp to the log file
Easier to parse than a strftime. And we can just add that one in a comment
anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 14:58:41 +10:00
Peter Hutterer 7f8222b351 wacom: add missing linebreaks to the yml log file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-15 14:58:41 +10:00
Peter Hutterer c014393adb wacom: time_to_bytes is obsolete now
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00
Peter Hutterer 1ea89d2f09 protocol: split GET_DIMENSIONS up into two messages
It's the same message with a different argument, let's try not to do
gymnastics in the Msg code just so we can return a tuple.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-14 07:37:30 +10:00