From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f170.google.com ([209.85.222.170]) by ewsd; Thu Jun 11 03:03:26 EDT 2020 Received: by mail-qk1-f170.google.com with SMTP id w3so4680560qkb.6 for <9front@9front.org>; Thu, 11 Jun 2020 00:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=CCk8OulhbPTh/UgKOsMZ3jwykAs2FHmfNkKvxoVg/do=; b=G92gSrAwJtJnf5A5qJyjIdV9CKFWPseMS0Oz6lEqjU7IhYU5BWwOkuPzsRIm7cQOtl 5B59J9Ld1Z5BYdLmlsN3gBOeFWkjRAq72+KlS+K0aaUa7gy69ufRkZDHbMrGRvb1SpIN cTBmsMKvCrX0kcvQP6siNfna+RPVIK5wU8XvrxzEFMk9jTWJFrK0G8XN/vkVfYmt3AVE WNoHJ2QucxjbkU390xg1o1zURyi/gP7ES7kRl8t0/B0PXRRnZ8Y0gCZOCcRJX+AcWmjw loWg2ROhdK4kqwWzLzOaJI6dN1sRDOANTeRiOBDWLqFFlChIoukJDtJGHUMh+NZtl0Rv Aa2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=CCk8OulhbPTh/UgKOsMZ3jwykAs2FHmfNkKvxoVg/do=; b=HVRjGlrfwoAQV9hZxqUpMn3cnlxSBxmOcXDYskV0/XrxnetwaTrdhTTfnCu8MExgfE g9rb3K9A8jDi5Lb8rkS5K8YTim7B5MmZUvtJavjVVyqMRRXUL9CGyblyT+0UdV9HuA9M hMqc2rB5u6z4ybs9cWNp2OdgIBrVi3YHtgZ+eI5hcaejDF9ahn2gTCXIh6uVsI2LYHdu LEJNYwkySdprSvX4JuFlg12bMs+ZT6SbnDWgS6E5dPTK880Xh4sSF/utEAAKMnjpzTQM DZQGYglun4PUvV/1MZtKwScfChE/41uU/oYfY27/I9cslVIvYrjvlwdUoeP4Kgt9o2Tg xOXw== X-Gm-Message-State: AOAM530X4mt7wu2n1xD0oMjriWCLA0x6zFVBHvop2nFHa4T+QTv/TmVv 1NZt4DZ2ifYket5z+U1Oo+ajQuYgiDSWbc1NLBJIRxOcgzY= X-Google-Smtp-Source: ABdhPJyhzmDdrRWJZX6xB6seF57jOJ0m7omssenln5dBOATwibh/NFSiKGqjGpuC7kUd5Vw4mRVsy4VX5dA3uibRFEI= X-Received: by 2002:a05:620a:122e:: with SMTP id v14mr6902949qkj.94.1591859003108; Thu, 11 Jun 2020 00:03:23 -0700 (PDT) MIME-Version: 1.0 From: Eli Cohen Date: Thu, 11 Jun 2020 00:03:12 -0700 Message-ID: Subject: new nusb/serial driver To: 9front@9front.org Content-Type: multipart/mixed; boundary="00000000000069d08e05a7c98e1b" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: stable shared HTTP just-in-time rails scripting browser --00000000000069d08e05a7c98e1b Content-Type: text/plain; charset="UTF-8" I have written an extremely limited and flaky CDC ACM driver for nusb/serial. it works well enough to communicate with my Arduino Mega 2560. it would be nice if someone smarter than me with similar hardware could look at this. --00000000000069d08e05a7c98e1b Content-Type: text/x-patch; charset="US-ASCII"; name="serial.patch" Content-Disposition: attachment; filename="serial.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kbafq2w20 T25seSBpbiAvdXNyL2dsZW5kYS9udXNiL3NlcmlhbDogY2RjLmMKZGlmZiAtdXIgL3N5cy9zcmMv Y21kL251c2Ivc2VyaWFsL21rZmlsZSAvdXNyL2dsZW5kYS9udXNiL3NlcmlhbC9ta2ZpbGUKLS0t IC9zeXMvc3JjL2NtZC9udXNiL3NlcmlhbC9ta2ZpbGUJRnJpIERlYyAxMyAwMDozMTozNCAyMDE5 CisrKyAvdXNyL2dsZW5kYS9udXNiL3NlcmlhbC9ta2ZpbGUJTW9uIEp1biAgOCAxODowMDozMyAy MDIwCkB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BlcGludHIpOwotCWlmKGVwaW4gPT0gLTEgfHwgZXBvdXQgPT0gLTEgfHwgKHNl ci0+aGFzZXBpbnRyICYmIGVwaW50ciA9PSAtMSkpCi0JCXJldHVybiAtMTsKKwlpZihlcGluID09 IC0xIHx8IGVwb3V0ID09IC0xIHx8IChzZXItPmhhc2VwaW50ciAmJiBlcGludHIgPT0gLTEpKXsK KwkJaWZjKys7CisJCWlmKGlmYyA+IDEpCisJCQlyZXR1cm4gLTE7CisJCWdvdG8gVE9QRklOREVQ UzsKKwl9CisJaWZjID0gb2lmYzsKIAogCWlmKG9wZW5lcHMoJnNlci0+cFtpZmNdLCBlcGluLCBl cG91dCwgZXBpbnRyKSA8IDApCiAJCXJldHVybiAtMTsKQEAgLTcxNCw2ICs3MjIsNyBAQAogZXh0 ZXJuIGludCBzbHByb2JlKFNlcmlhbCAqc2VyKTsKIGV4dGVybiBpbnQgY2hwcm9iZShTZXJpYWwg KnNlcik7CiBleHRlcm4gaW50IHVjb25zcHJvYmUoU2VyaWFsICpzZXIpOworZXh0ZXJuIGludCBj ZGNwcm9iZShTZXJpYWwgKnNlcik7CiAKIHZvaWQKIHRocmVhZG1haW4oaW50IGFyZ2MsIGNoYXIq IGFyZ3ZbXSkKQEAgLTc1MCw3ICs3NTksOCBAQAogCSYmIGZ0cHJvYmUoc2VyKQogCSYmIHNscHJv YmUoc2VyKQogCSYmIHBscHJvYmUoc2VyKQotCSYmIGNocHJvYmUoc2VyKSkKKwkmJiBjaHByb2Jl KHNlcikKKwkmJiBjZGNwcm9iZShzZXIpKQogCQlzeXNmYXRhbCgibm8gc2VyaWFsIGRldmljZXMg Zm91bmQiKTsKIAogCWZvcihpID0gMDsgaSA8IHNlci0+bmlmY3M7IGkrKyl7Cg== --00000000000069d08e05a7c98e1b Content-Type: text/x-csrc; charset="US-ASCII"; name="cdc.c" Content-Disposition: attachment; filename="cdc.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kbafqa4b1 I2luY2x1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