9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] nusb/serial: fix pl2303 usbcmd error checks
@ 2022-01-01 22:51 Michael Forney
  2022-02-28 23:55 ` [9front] " Michael Forney
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Forney @ 2022-01-01 22:51 UTC (permalink / raw)
  To: 9front


Since e0087b2a, usbcmd with Rh2d returns the size of the data stage
(excluding the setup packet), so adjust the expected return values
accordingly.
---
diff 9c5ac15e11ffa2c5e57796c3a32baa769cce9aac 6b850d84118c8ee7e66b12daab17ef48fe65176e
--- a/sys/src/cmd/nusb/serial/prolific.c	Wed Feb 10 01:00:05 2021
+++ b/sys/src/cmd/nusb/serial/prolific.c	Sat Jan  1 14:51:18 2022
@@ -281,7 +281,7 @@
 	dsprint(2, "serial: vendorwrite val: 0x%x idx:%d\n", val, index);
 	res = usbcmd(ser->dev, Rh2d | Rvendor | Rdev, VendorWriteReq,
 		val, index, nil, 0);
-	if(res != 8) fprint(2, "serial: vendorwrite failed with res=%d\n", res);
+	if(res != 0) fprint(2, "serial: vendorwrite failed with res=%d\n", res);
 	return res;
 }
 
@@ -373,7 +373,7 @@
 		dumpbuf(buf, sizeof buf);
 	res = usbcmd(ser->dev, Rh2d | Rclass | Riface, SetLineReq,
 		0, 0, buf, sizeof buf);
-	if(res != 8+ParamReqSz){
+	if(res != ParamReqSz){
 		fprint(2, "serial: plsetparam failed with res=%d\n", res);
 		if(res >= 0) werrstr("plsetparam failed with res=%d", res);
 		return -1;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [9front] Re: [PATCH] nusb/serial: fix pl2303 usbcmd error checks
  2022-01-01 22:51 [9front] [PATCH] nusb/serial: fix pl2303 usbcmd error checks Michael Forney
@ 2022-02-28 23:55 ` Michael Forney
  2022-03-02  4:08   ` ori
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Forney @ 2022-02-28 23:55 UTC (permalink / raw)
  To: 9front

On 2022-01-01-22, Michael Forney <mforney@mforney.org> wrote:
> Since e0087b2a, usbcmd with Rh2d returns the size of the data stage
> (excluding the setup packet), so adjust the expected return values
> accordingly.

Ping. nusb/serial doesn't work at all with Prolific devices without this patch.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Re: [PATCH] nusb/serial: fix pl2303 usbcmd error checks
  2022-02-28 23:55 ` [9front] " Michael Forney
@ 2022-03-02  4:08   ` ori
  2022-03-02 19:09     ` cinap_lenrek
  2022-03-02 19:12     ` cinap_lenrek
  0 siblings, 2 replies; 7+ messages in thread
From: ori @ 2022-03-02  4:08 UTC (permalink / raw)
  To: 9front

Quoth Michael Forney <mforney@mforney.org>:
> On 2022-01-01-22, Michael Forney <mforney@mforney.org> wrote:
> > Since e0087b2a, usbcmd with Rh2d returns the size of the data stage
> > (excluding the setup packet), so adjust the expected return values
> > accordingly.
> 
> Ping. nusb/serial doesn't work at all with Prolific devices without this patch.
> 

currently, I have no usb serial devices to test with,
but it looks good on reading -- committed.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Re: [PATCH] nusb/serial: fix pl2303 usbcmd error checks
  2022-03-02  4:08   ` ori
@ 2022-03-02 19:09     ` cinap_lenrek
  2022-03-02 19:12     ` cinap_lenrek
  1 sibling, 0 replies; 7+ messages in thread
From: cinap_lenrek @ 2022-03-02 19:09 UTC (permalink / raw)
  To: 9front

i have a prolific usb serial adapter and had no issues so far.

let me try it if theres any regression with the patch.

but it makes sense to me.

--
cinap

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Re: [PATCH] nusb/serial: fix pl2303 usbcmd error checks
  2022-03-02  4:08   ` ori
  2022-03-02 19:09     ` cinap_lenrek
@ 2022-03-02 19:12     ` cinap_lenrek
  2022-03-02 21:06       ` Michael Forney
  1 sibling, 1 reply; 7+ messages in thread
From: cinap_lenrek @ 2022-03-02 19:12 UTC (permalink / raw)
  To: 9front

still seems to work fine with the latest patch.

attach 8 1a86 7523 0000ff 55b22

--
cinap

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Re: [PATCH] nusb/serial: fix pl2303 usbcmd error checks
  2022-03-02 19:12     ` cinap_lenrek
@ 2022-03-02 21:06       ` Michael Forney
  2022-03-04 10:47         ` cinap_lenrek
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Forney @ 2022-03-02 21:06 UTC (permalink / raw)
  To: 9front

On 2022-03-02, cinap_lenrek@felloff.net <cinap_lenrek@felloff.net> wrote:
> still seems to work fine with the latest patch.
>
> attach 8 1a86 7523 0000ff 55b22

Those device IDs match ch340.c, not prolific.c.

The prolific one was bugged since the referenced commit:
http://git.9front.org/plan9front/plan9front/e0087b2a78d7229d8d2b148b8def688be6639797/commit.html

In prolific.c, vendorwrite and plsetparam call usbcmd with Rh2d and
some ndata (0 or ParamReqSz), and then errors out when the result is
not 8+ndata. That previous commit made usbcmd with Rh2d return ndata,
not 8+ndata, so it is now failing.

Here are the error messages I was getting:

term% nusb/serial 7
serial: vendorwrite failed with res=0
serial: vendorwrite failed with res=0
serial: vendorwrite failed with res=0
serial: vendorwrite failed with res=0
serial: vendorwrite failed with res=0
term% echo 'b 19200' >/dev/eiaU7ctl
serial: vendorwrite failed with res=0
serial: vendorwrite failed with res=0
serial: plsetparam failed with res=7
echo: write error: bad control request

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Re: [PATCH] nusb/serial: fix pl2303 usbcmd error checks
  2022-03-02 21:06       ` Michael Forney
@ 2022-03-04 10:47         ` cinap_lenrek
  0 siblings, 0 replies; 7+ messages in thread
From: cinap_lenrek @ 2022-03-04 10:47 UTC (permalink / raw)
  To: 9front

yeah, makes sense.

--
cinap

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-04 11:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-01 22:51 [9front] [PATCH] nusb/serial: fix pl2303 usbcmd error checks Michael Forney
2022-02-28 23:55 ` [9front] " Michael Forney
2022-03-02  4:08   ` ori
2022-03-02 19:09     ` cinap_lenrek
2022-03-02 19:12     ` cinap_lenrek
2022-03-02 21:06       ` Michael Forney
2022-03-04 10:47         ` cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).