Re: Read/write serial data

Jeff Mitchell <[email protected]> Mon, 26 Oct 2020 10:10:55 -0400
Newsgroups gmane.comp.lang.jython.user
Message-ID <CAAdVdyiXQDtp5R+aAYSNCxGuFit6JCC2qE_+0qdnnCVH9vkLYA@mail.gmail.com>
--===============8701376454196872382==
Content-Type: multipart/alternative; boundary="0000000000004b6e8005b29380c8"

--0000000000004b6e8005b29380c8
Content-Type: text/plain; charset="UTF-8"

May be way off base for .. if you "dabble with programming" (meaning you're
not at top of your game right now), then is using jython for serial really
the wisest choice? ie: pure python would do better, since it would be a
more concrete thing - remove a few uncertainties. The main advantage of
jython for you would be that you could also take advantage of some java
libraries.

Strikes me for now, if you're essentially writing pure python code to talk
serial, do it in CPython so you have less surface area for issues; if you
then get that working, then run it in jython and see if it still works, or
if it fails; this could help you identify if theres a gap in jython or a
bug in your code, and then once debugged, you could move on to the parts
that need java. If you don't need java at all, then jython is probably not
what you need.

So, I suggest one step at a time.. debug the python code, as pure python,
first, make your life easier :)

On Fri, Oct 23, 2020 at 6:54 PM Jon Christopher <[email protected]>
wrote:

> Not jython-specific, but have you tried pyserial by any chance?
>
> It looks pretty simple:
>
> https://pyserial.readthedocs.io/en/latest/shortintro.html
> <https://urldefense.com/v3/__https://pyserial.readthedocs.io/en/latest/shortintro.html__;!!Bqsxq_o9!j9GtPJ3b0SAlYpyrm_V5GFdXY-3_8Wg0TOZT7kNHE8uftc1xxTjtmPVf9uetHHptpoE$>
>
> >>> ser = serial.Serial('COM3', 38400, timeout=0,...                     parity=serial.PARITY_EVEN, rtscts=1)>>> s = ser.read(100)       # read up to one hundred bytes...                         # or as much is in the buffer
>
>
>
>
>
> On Fri, Oct 23, 2020 at 2:34 PM James Kelly <[email protected]> wrote:
>
>> Hi,
>> I'm aware of the fact that I'm about to ask a lot of the group but I do
>> need the help. I dabble with programming but have to acknowledge that what
>> I need is beyond my abilities to develop; so I hope the group will take
>> mercy on an old retired model railroader.
>> I have an Arduino that I need to pass ASCII to/from a computer through a
>> USB COM1 port.  I want to use Jython as I am running Win-10 with a JRE.
>> I find a lot of code samples, most using the RXTX library, but nothing
>> demonstrating a way the user can input data to send and and at least a
>> print statement to show the ASCII input. Most code seems to be in Java and
>> I know from reading that it can be used from within Jython.
>> I'm old school (before OOP) and to be honest I find the code snippets to
>> be confusing. Is there a working example on-line or in a reference book
>> that demonstrates what I need -- start to finish?
>> Jim K.
>> Houston TX.
>> _______________________________________________
>> Jython-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/jython-users
>> <https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/jython-users__;!!Bqsxq_o9!j9GtPJ3b0SAlYpyrm_V5GFdXY-3_8Wg0TOZT7kNHE8uftc1xxTjtmPVf9uetuNZk1Zo$>
>>
> _______________________________________________
> Jython-users mailing list
> [email protected]
>
> https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/jython-users__;!!Bqsxq_o9!j9GtPJ3b0SAlYpyrm_V5GFdXY-3_8Wg0TOZT7kNHE8uftc1xxTjtmPVf9uetuNZk1Zo$
>


-- 

Jeff Mitchell

Sr Application Architect

Zayo | Our Fiber Fuels Global Innovation

1821 30th Street | Unit A | Boulder, CO  80301

Desk: 999.999.9999 | Cell: 999.999.9999

[email protected]

Purpose <http://zayo.is/signature-purpose> | Network Map
<http://zayo.is/signature-network> | LinkedIn
<http://zayo.is/signature-linkedin> | Twitter
<http://zayo.is/signature-twitter>

This communication is the property of Zayo and may contain confidential or
privileged information. If you have received this communication in error,
please promptly notify the sender by reply e-mail and destroy all copies of
the communication and any attachments.


He who dies with the best barbecue sauce, wins.

--0000000000004b6e8005b29380c8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">May be way off base for .. if you &quot;dabble with progra=
mming&quot; (meaning you&#39;re not at top of your game right now), then is=
 using jython for serial really the wisest choice? ie: pure python would do=
 better, since it would be a more concrete thing - remove a few uncertainti=
es. The main advantage of jython for you would be that you could also take =
advantage of some java libraries.<div><br></div><div>Strikes me for now, if=
 you&#39;re essentially writing pure python code to talk serial, do it in C=
Python so you have less surface area for issues; if you then get that worki=
ng, then run it in jython and see if it still works, or if it fails; this c=
ould help you identify if theres a gap in jython or a bug in your code, and=
 then once debugged, you could move on to the parts that need java. If you =
don&#39;t need java at all, then jython is probably not what you need.</div=
><div><br></div><div>So, I suggest one step at a time.. debug the python co=
de, as pure python, first, make your life easier :)</div></div><br><div cla=
ss=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Oct 23, 20=
20 at 6:54 PM Jon Christopher &lt;<a href=3D"mailto:[email protected]=
om">[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(20=
4,204,204);padding-left:1ex"><div dir=3D"ltr">Not jython-specific, but have=
 you tried pyserial by any chance?<div><br></div><div>It looks pretty simpl=
e:</div><div><br></div><div><a href=3D"https://urldefense.com/v3/__https://=
pyserial.readthedocs.io/en/latest/shortintro.html__;!!Bqsxq_o9!j9GtPJ3b0SAl=
Ypyrm_V5GFdXY-3_8Wg0TOZT7kNHE8uftc1xxTjtmPVf9uetHHptpoE$" target=3D"_blank"=
>https://pyserial.readthedocs.io/en/latest/shortintro.html</a><br></div><di=
v><br></div><div><pre style=3D"box-sizing:border-box;font-family:SFMono-Reg=
ular,Menlo,Monaco,Consolas,&quot;Liberation Mono&quot;,&quot;Courier New&qu=
ot;,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;paddi=
ng:12px;overflow:auto;line-height:normal;color:rgb(64,64,64)"><span style=
=3D"box-sizing:border-box;color:rgb(198,93,9);font-weight:bold">&gt;&gt;&gt=
; </span><span style=3D"box-sizing:border-box">ser</span> <span style=3D"bo=
x-sizing:border-box;color:rgb(102,102,102)">=3D</span> <span style=3D"box-s=
izing:border-box">serial</span><span style=3D"box-sizing:border-box;color:r=
gb(102,102,102)">.</span><span style=3D"box-sizing:border-box">Serial</span=
><span style=3D"box-sizing:border-box">(</span><span style=3D"box-sizing:bo=
rder-box;color:rgb(64,112,160)">&#39;COM3&#39;</span><span style=3D"box-siz=
ing:border-box">,</span> <span style=3D"box-sizing:border-box;color:rgb(32,=
128,80)">38400</span><span style=3D"box-sizing:border-box">,</span> <span s=
tyle=3D"box-sizing:border-box">timeout</span><span style=3D"box-sizing:bord=
er-box;color:rgb(102,102,102)">=3D</span><span style=3D"box-sizing:border-b=
ox;color:rgb(32,128,80)">0</span><span style=3D"box-sizing:border-box">,</s=
pan>
<span style=3D"box-sizing:border-box;color:rgb(198,93,9);font-weight:bold">=
... </span>                    <span style=3D"box-sizing:border-box">parity=
</span><span style=3D"box-sizing:border-box;color:rgb(102,102,102)">=3D</sp=
an><span style=3D"box-sizing:border-box">serial</span><span style=3D"box-si=
zing:border-box;color:rgb(102,102,102)">.</span><span style=3D"box-sizing:b=
order-box">PARITY_EVEN</span><span style=3D"box-sizing:border-box">,</span>=
 <span style=3D"box-sizing:border-box">rtscts</span><span style=3D"box-sizi=
ng:border-box;color:rgb(102,102,102)">=3D</span><span style=3D"box-sizing:b=
order-box;color:rgb(32,128,80)">1</span><span style=3D"box-sizing:border-bo=
x">)</span>
<span style=3D"box-sizing:border-box;color:rgb(198,93,9);font-weight:bold">=
&gt;&gt;&gt; </span><span style=3D"box-sizing:border-box">s</span> <span st=
yle=3D"box-sizing:border-box;color:rgb(102,102,102)">=3D</span> <span style=
=3D"box-sizing:border-box">ser</span><span style=3D"box-sizing:border-box;c=
olor:rgb(102,102,102)">.</span><span style=3D"box-sizing:border-box">read</=
span><span style=3D"box-sizing:border-box">(</span><span style=3D"box-sizin=
g:border-box;color:rgb(32,128,80)">100</span><span style=3D"box-sizing:bord=
er-box">)</span>       <span style=3D"box-sizing:border-box;color:rgb(64,12=
8,144);font-style:italic"># read up to one hundred bytes</span>
<span style=3D"box-sizing:border-box;color:rgb(198,93,9);font-weight:bold">=
... </span>                        <span style=3D"box-sizing:border-box;col=
or:rgb(64,128,144);font-style:italic"># or as much is in the buffer</span><=
/pre><pre style=3D"box-sizing:border-box;font-family:SFMono-Regular,Menlo,M=
onaco,Consolas,&quot;Liberation Mono&quot;,&quot;Courier New&quot;,Courier,=
monospace;font-size:12px;margin-top:0px;margin-bottom:0px;padding:12px;over=
flow:auto;line-height:normal;color:rgb(64,64,64)"><span style=3D"box-sizing=
:border-box;color:rgb(64,128,144);font-style:italic"><br></span></pre><pre =
style=3D"box-sizing:border-box;font-family:SFMono-Regular,Menlo,Monaco,Cons=
olas,&quot;Liberation Mono&quot;,&quot;Courier New&quot;,Courier,monospace;=
font-size:12px;margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;=
line-height:normal;color:rgb(64,64,64)"><br></pre></div><div><br></div></di=
v><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On F=
ri, Oct 23, 2020 at 2:34 PM James Kelly &lt;<a href=3D"mailto:jwkelly49@gma=
il.com" target=3D"_blank">[email protected]</a>&gt; wrote:<br></div><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:=
1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div class=3D=
"gmail_default" style=3D"font-size:large">Hi,<br>I&#39;m aware of the fact =
that I&#39;m about to ask a lot of the group but I do need the help. I dabb=
le with programming but have to acknowledge that what I need is beyond my a=
bilities to develop; so I hope the group will take mercy on an old retired =
model railroader.<br>I have an Arduino that I need to pass ASCII to/from a =
computer through a USB COM1 port.=C2=A0 I want to use Jython as I am runnin=
g Win-10 with a JRE.<br>I find a lot of code samples, most using the RXTX l=
ibrary, but nothing demonstrating a way the user can input data to send and=
 and at least a print statement to show the ASCII input. Most code seems to=
 be in Java and I know from reading that it can be used from within Jython.=
<br>I&#39;m old school (before OOP) and to be honest I find the code snippe=
ts to be confusing. Is there a working example on-line or in a reference bo=
ok that demonstrates what I need -- start to finish?<br>Jim K.<br>Houston T=
X.<br></div></div>
_______________________________________________<br>
Jython-users mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">Jyt=
[email protected]</a><br>
<a href=3D"https://urldefense.com/v3/__https://lists.sourceforge.net/lists/=
listinfo/jython-users__;!!Bqsxq_o9!j9GtPJ3b0SAlYpyrm_V5GFdXY-3_8Wg0TOZT7kNH=
E8uftc1xxTjtmPVf9uetuNZk1Zo$" rel=3D"noreferrer" target=3D"_blank">https://=
lists.sourceforge.net/lists/listinfo/jython-users</a><br>
</blockquote></div>
_______________________________________________<br>
Jython-users mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">Jyt=
[email protected]</a><br>
<a href=3D"https://urldefense.com/v3/__https://lists.sourceforge.net/lists/=
listinfo/jython-users__;!!Bqsxq_o9!j9GtPJ3b0SAlYpyrm_V5GFdXY-3_8Wg0TOZT7kNH=
E8uftc1xxTjtmPVf9uetuNZk1Zo$" rel=3D"noreferrer" target=3D"_blank">https://=
urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/jython-use=
rs__;!!Bqsxq_o9!j9GtPJ3b0SAlYpyrm_V5GFdXY-3_8Wg0TOZT7kNHE8uftc1xxTjtmPVf9ue=
tuNZk1Zo$</a> <br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"l=
ine-height:1.656;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size=
:10pt;font-family:&quot;Trebuchet MS&quot;;color:rgb(127,127,127);font-weig=
ht:700;vertical-align:baseline;white-space:pre-wrap">Jeff Mitchell</span></=
p><p dir=3D"ltr" style=3D"line-height:1.656;margin-top:0pt;margin-bottom:0p=
t"><span style=3D"font-size:10pt;font-family:&quot;Trebuchet MS&quot;;color=
:rgb(127,127,127);font-weight:700;vertical-align:baseline;white-space:pre-w=
rap">Sr Application Architect</span></p><p dir=3D"ltr" style=3D"line-height=
:1.656;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:12pt;font=
-family:&quot;Trebuchet MS&quot;;color:rgb(247,150,70);font-weight:700;vert=
ical-align:baseline;white-space:pre-wrap">Zayo | Our Fiber Fuels Global Inn=
ovation</span></p><p dir=3D"ltr" style=3D"line-height:1.656;margin-top:0pt;=
margin-bottom:0pt"><span style=3D"font-size:10pt;font-family:&quot;Trebuche=
t MS&quot;;color:rgb(127,127,127);font-weight:700;vertical-align:baseline;w=
hite-space:pre-wrap">1821 30th Street | Unit A | Boulder, CO=C2=A0 80301</s=
pan></p><p dir=3D"ltr" style=3D"line-height:1.656;margin-top:0pt;margin-bot=
tom:0pt"><span style=3D"font-size:10pt;font-family:&quot;Trebuchet MS&quot;=
;color:rgb(127,127,127);font-weight:700;vertical-align:baseline;white-space=
:pre-wrap">Desk: 999.999.9999 | Cell: 999.999.9999</span></p><p dir=3D"ltr"=
 style=3D"line-height:1.656;margin-top:0pt;margin-bottom:0pt"><span style=
=3D"font-size:10pt;font-family:&quot;Trebuchet MS&quot;;color:rgb(17,85,204=
);font-weight:700;vertical-align:baseline;white-space:pre-wrap"><a href=3D"=
mailto:[email protected]" target=3D"_blank">[email protected]</a>=
</span></p><p dir=3D"ltr" style=3D"line-height:1.656;margin-top:0pt;margin-=
bottom:0pt"><a href=3D"http://zayo.is/signature-purpose" target=3D"_blank">=
<span style=3D"font-size:9.5pt;font-family:&quot;Trebuchet MS&quot;;color:r=
gb(17,85,204);font-weight:700;vertical-align:baseline;white-space:pre-wrap"=
>Purpose</span></a><span style=3D"font-size:9.5pt;font-family:&quot;Trebuch=
et MS&quot;;font-weight:700;vertical-align:baseline;white-space:pre-wrap"> =
|</span><a href=3D"http://zayo.is/signature-network" target=3D"_blank"><spa=
n style=3D"font-size:9.5pt;font-family:&quot;Trebuchet MS&quot;;color:rgb(3=
4,34,34);font-weight:700;vertical-align:baseline;white-space:pre-wrap"> </s=
pan><span style=3D"font-size:9.5pt;font-family:&quot;Trebuchet MS&quot;;col=
or:rgb(17,85,204);font-weight:700;vertical-align:baseline;white-space:pre-w=
rap">Network Map</span></a><span style=3D"font-size:9.5pt;font-family:&quot=
;Trebuchet MS&quot;;font-weight:700;vertical-align:baseline;white-space:pre=
-wrap"> |</span><a href=3D"http://zayo.is/signature-linkedin" target=3D"_bl=
ank"><span style=3D"font-size:9.5pt;font-family:&quot;Trebuchet MS&quot;;co=
lor:rgb(34,34,34);font-weight:700;vertical-align:baseline;white-space:pre-w=
rap"> </span><span style=3D"font-size:9.5pt;font-family:&quot;Trebuchet MS&=
quot;;color:rgb(17,85,204);font-weight:700;vertical-align:baseline;white-sp=
ace:pre-wrap">LinkedIn</span></a><span style=3D"font-size:9.5pt;font-family=
:&quot;Trebuchet MS&quot;;font-weight:700;vertical-align:baseline;white-spa=
ce:pre-wrap"> | </span><a href=3D"http://zayo.is/signature-twitter" target=
=3D"_blank"><span style=3D"font-size:9.5pt;font-family:&quot;Trebuchet MS&q=
uot;;color:rgb(17,85,204);font-weight:700;vertical-align:baseline;white-spa=
ce:pre-wrap">Twitter</span></a></p><br><p dir=3D"ltr" style=3D"line-height:=
1.656;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:9pt;font-f=
amily:&quot;Trebuchet MS&quot;;color:rgb(127,127,127);font-weight:700;font-=
style:italic;vertical-align:baseline;white-space:pre-wrap">This communicati=
on is the property of Zayo and may contain confidential or privileged infor=
mation. If you have received this communication in error, please promptly n=
otify the sender by reply e-mail and destroy all copies of the communicatio=
n and any attachments.</span></p><p style=3D"line-height:1.656;margin-top:0=
pt;margin-bottom:0pt"><span style=3D"font-size:9pt;font-family:&quot;Trebuc=
het MS&quot;;color:rgb(127,127,127);font-weight:700;font-style:italic;verti=
cal-align:baseline;white-space:pre-wrap"><br></span></p><p style=3D"line-he=
ight:1.656;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:9pt;f=
ont-family:&quot;Trebuchet MS&quot;;color:rgb(127,127,127);font-weight:700;=
font-style:italic;vertical-align:baseline;white-space:pre-wrap">He who dies=
 with the best barbecue sauce, wins.</span></p></span></div></div>

--0000000000004b6e8005b29380c8--


--===============8701376454196872382==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============8701376454196872382==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Jython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-users

--===============8701376454196872382==--