ref: 53fe82ee861967f0c02dbec7901660470da79098
parent: c8d87b22d50a17b8832019a93b9293fef19fbd02
author: Igor Böhm <igor@9lab.org>
date: Sun Jan 14 20:11:18 EST 2024
nusb/ptp: transaction IDs are sequences of numbers starting with 0 (thanks unobe) According to 'Digital Camera connectivity solutions using the picture transfer protocol' [1] Section 2.3: "the PTP is specified using the transaction model. A transaction is composed of a request operation, followed by an optional data transfer and a response. Each transaction has an identifier (TransactionID) that is session unique and comprise of a 32 bit unsigned number. The transaction IDs are a sequence of numbers starting with 0x00000000 (for the SessionOpen transaction) and increasing with every following operation." [1] https://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/f2012/jmv87/site/files/PTP%20Protocol.pdf
--- a/sys/man/4/nusb
+++ b/sys/man/4/nusb
@@ -194,6 +194,10 @@
The
.B ctl
file supplies the device geometry and partitions when read.
+.I Ptp
+configures and exposes a camera's (and often a mobile
+device's) storage to allow transferring data via the
+Picture Transfer Protocol (PTP).
.SS Ethernet
.I Ether
handles USB ethernet devices. The file system provided is
--- a/sys/src/cmd/nusb/ptp/ptp.c
+++ b/sys/src/cmd/nusb/ptp/ptp.c
@@ -75,9 +75,8 @@
static int debug = 0;
static ulong time0;
-static int maxpacket = 64;
-static int sessionId = 1;
-static int transId = 1;
+static int sessionId;
+static int transId;
static Node **nodes;
static int nnodes;
@@ -556,7 +555,7 @@
}
/*
- * another proc migh'v come in and done it for us,
+ * another proc might've come in and done it for us,
* so check the cache again.
*/
if(y = cachednode(path, &f))
@@ -1048,6 +1047,7 @@
sendp(iochan, ioproc());
sessionId = getpid();
+ transId = 0;
if(ptprpc(nil, OpenSession, 1, sessionId) < 0)
sysfatal("open session: %r");