9front - general discussion about 9front
 help / color / mirror / Atom feed
From: cinap_lenrek@felloff.net
To: 9front@9front.org
Subject: Re: [9front] recent kernel changes break built-in wacom serial tablet on
Date: Sun, 14 Jan 2024 21:24:17 +0100	[thread overview]
Message-ID: <81135DE0B2F485EDD907E472B2C493A4@felloff.net> (raw)
In-Reply-To: <147EB4543ABBB0841A8F54F2B9AB766B@gaff.inri.net>

interesting.

there was some changes in how the console uarts get initialized,
however, given that you can still change the cursor horizontally
means we'r receiving bytes from the tablet fine. maybe it
was caused by scheduler changes...

it seems that the code that tries to re-synchronize with the
packet stream is somehow desynchronized.

the code basically looks for a start byte "head" that has bit 7 (0x80)
set and then assume 9 more bytes for the full packet afterwards:

int
findheader(Tablet* t)
{
	uchar c;
	
	do {
		if(read(t->ser, &c, 1) < 1) return -1;
	} while((c & 0x80) == 0);
	return c;
}

Message*
readpacket(Tablet* t)
{
	uchar buf[9];
	int head;
	Message *m;

	head = findheader(t);
	if(head < 0) return 0;
	if(readn(t->ser, buf, 9) < 9) return 0;
	
	m = calloc(sizeof(Message), 1);
	incref(m);
	
	m->b = head & 7;
	m->x = (buf[0] << 9) | (buf[1] << 2) | ((buf[5] >> 5) & 3);
	m->y = (buf[2] << 9) | (buf[3] << 2) | ((buf[5] >> 3) & 3);
	m->p = ((buf[5] & 7) << 7) | buf[4];
	
	m->p *= MAX;
	m->p /= t->pmax;
	m->x *= t->sx;
	m->x /= t->xmax;
	m->y *= t->sy;
	m->y /= t->ymax;
	
	m->msg = smprint("m %d %d %d %d\n", m->x, m->y, m->b, m->p);
	return m;
}

i'd start debugging here. it is possible there is some crap in
the uart fifo when we switch the baud-rate and the re-synchronizatoin
code fails to recover from that.

also the serial mode might be different? maybe it is trying todo
software flow-control or something? can you cat:

cat /dev/eia2status

maybe one test you could do is using dd with a block size of 10 bytes:

</dev/eia2data {while(){dd -bs 10 -count 1 | xd -x1}}

--
cinap

  parent reply	other threads:[~2024-01-14 20:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12 21:53 sl
2024-01-12 21:59 ` sl
2024-01-14 20:24 ` cinap_lenrek [this message]
2024-01-14 20:51 ` cinap_lenrek
2024-01-14 21:28 ` cinap_lenrek
2024-01-14 21:38   ` [9front] " Stanley Lieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81135DE0B2F485EDD907E472B2C493A4@felloff.net \
    --to=cinap_lenrek@felloff.net \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).