mirror of
https://github.com/meshtastic/python.git
synced 2025-12-31 03:47:55 -05:00
1.1.23 fix #41 pyserial also drives usb control signals wrong on windows
This commit is contained in:
@@ -806,11 +806,11 @@ class SerialInterface(StreamInterface):
|
||||
|
||||
# rts=False Needed to prevent TBEAMs resetting on OSX, because rts is connected to reset
|
||||
self.stream.port = devPath
|
||||
# OS-X seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
|
||||
# OS-X/Windows seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
|
||||
# control and will always drive RTS either high or low (rather than letting the CP102 leave
|
||||
# it as an open-collector floating pin). Since it is going to drive it anyways we want to make
|
||||
# sure it is driven low, so that the TBEAM won't reset
|
||||
if platform.system() == 'Darwin':
|
||||
if platform.system() != 'Linux':
|
||||
self.stream.rts = False
|
||||
self.stream.open()
|
||||
|
||||
@@ -820,7 +820,7 @@ class SerialInterface(StreamInterface):
|
||||
def _disconnected(self):
|
||||
"""We override the superclass implementation to close our port"""
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
if platform.system() != 'Linux':
|
||||
self.stream.rts = True # Return RTS high, so that the reset button still works
|
||||
|
||||
StreamInterface._disconnected(self)
|
||||
@@ -1822,11 +1822,11 @@ debugOut {stream} – If a stream is provided, any debug serial output from
|
||||
|
||||
# rts=False Needed to prevent TBEAMs resetting on OSX, because rts is connected to reset
|
||||
self.stream.port = devPath
|
||||
# OS-X seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
|
||||
# OS-X/Windows seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
|
||||
# control and will always drive RTS either high or low (rather than letting the CP102 leave
|
||||
# it as an open-collector floating pin). Since it is going to drive it anyways we want to make
|
||||
# sure it is driven low, so that the TBEAM won't reset
|
||||
if platform.system() == 'Darwin':
|
||||
if platform.system() != 'Linux':
|
||||
self.stream.rts = False
|
||||
self.stream.open()
|
||||
|
||||
@@ -1836,7 +1836,7 @@ debugOut {stream} – If a stream is provided, any debug serial output from
|
||||
def _disconnected(self):
|
||||
"""We override the superclass implementation to close our port"""
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
if platform.system() != 'Linux':
|
||||
self.stream.rts = True # Return RTS high, so that the reset button still works
|
||||
|
||||
StreamInterface._disconnected(self)</code></pre>
|
||||
|
||||
@@ -49,7 +49,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
syntax='proto3',
|
||||
serialized_options=b'\n\023com.geeksville.meshB\010PortnumsH\003',
|
||||
create_key=_descriptor._internal_create_key,
|
||||
serialized_pb=b'\n\x0eportnums.proto*\x93\x01\n\x07PortNum\x12\x0f\n\x0bUNKNOWN_APP\x10\x00\x12\x14\n\x10TEXT_MESSAGE_APP\x10\x01\x12\x17\n\x13REMOTE_HARDWARE_APP\x10\x02\x12\x10\n\x0cPOSITION_APP\x10\x03\x12\x10\n\x0cNODEINFO_APP\x10\x04\x12\x10\n\x0bPRIVATE_APP\x10\x80\x02\x12\x12\n\rIP_TUNNEL_APP\x10\x80\x08\x42!\n\x13\x63om.geeksville.meshB\x08PortnumsH\x03\x62\x06proto3'
|
||||
serialized_pb=b'\n\x0eportnums.proto*\xa2\x01\n\x07PortNum\x12\x0f\n\x0bUNKNOWN_APP\x10\x00\x12\x14\n\x10TEXT_MESSAGE_APP\x10\x01\x12\x17\n\x13REMOTE_HARDWARE_APP\x10\x02\x12\x10\n\x0cPOSITION_APP\x10\x03\x12\x10\n\x0cNODEINFO_APP\x10\x04\x12\r\n\tREPLY_APP\x10 \x12\x10\n\x0bPRIVATE_APP\x10\x80\x02\x12\x12\n\rIP_TUNNEL_APP\x10\x80\x08\x42!\n\x13\x63om.geeksville.meshB\x08PortnumsH\x03\x62\x06proto3'
|
||||
)
|
||||
|
||||
_PORTNUM = _descriptor.EnumDescriptor(
|
||||
@@ -85,12 +85,17 @@ _PORTNUM = _descriptor.EnumDescriptor(
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='PRIVATE_APP', index=5, number=256,
|
||||
name='REPLY_APP', index=5, number=32,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='IP_TUNNEL_APP', index=6, number=1024,
|
||||
name='PRIVATE_APP', index=6, number=256,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='IP_TUNNEL_APP', index=7, number=1024,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
@@ -98,7 +103,7 @@ _PORTNUM = _descriptor.EnumDescriptor(
|
||||
containing_type=None,
|
||||
serialized_options=None,
|
||||
serialized_start=19,
|
||||
serialized_end=166,
|
||||
serialized_end=181,
|
||||
)
|
||||
_sym_db.RegisterEnumDescriptor(_PORTNUM)
|
||||
|
||||
@@ -108,6 +113,7 @@ TEXT_MESSAGE_APP = 1
|
||||
REMOTE_HARDWARE_APP = 2
|
||||
POSITION_APP = 3
|
||||
NODEINFO_APP = 4
|
||||
REPLY_APP = 32
|
||||
PRIVATE_APP = 256
|
||||
IP_TUNNEL_APP = 1024
|
||||
|
||||
|
||||
@@ -70,7 +70,14 @@ class RemoteHardwareClient:
|
||||
r = remote_hardware_pb2.HardwareMessage()
|
||||
r.typ = remote_hardware_pb2.HardwareMessage.Type.READ_GPIOS
|
||||
r.gpio_mask = mask
|
||||
return self.iface.sendData(r, nodeid, portnums_pb2.REMOTE_HARDWARE_APP, wantAck = True)</code></pre>
|
||||
return self.iface.sendData(r, nodeid, portnums_pb2.REMOTE_HARDWARE_APP, wantAck = True)
|
||||
|
||||
def watchGPIOs(self, nodeid, mask):
|
||||
"""Watch the specified bits from GPIO inputs on the device for changes"""
|
||||
r = remote_hardware_pb2.HardwareMessage()
|
||||
r.typ = remote_hardware_pb2.HardwareMessage.Type.WATCH_GPIOS
|
||||
r.gpio_mask = mask
|
||||
return self.iface.sendData(r, nodeid, portnums_pb2.REMOTE_HARDWARE_APP, wantAck = True) </code></pre>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
@@ -152,7 +159,14 @@ code for how you can connect to your own custom meshtastic services</p>
|
||||
r = remote_hardware_pb2.HardwareMessage()
|
||||
r.typ = remote_hardware_pb2.HardwareMessage.Type.READ_GPIOS
|
||||
r.gpio_mask = mask
|
||||
return self.iface.sendData(r, nodeid, portnums_pb2.REMOTE_HARDWARE_APP, wantAck = True)</code></pre>
|
||||
return self.iface.sendData(r, nodeid, portnums_pb2.REMOTE_HARDWARE_APP, wantAck = True)
|
||||
|
||||
def watchGPIOs(self, nodeid, mask):
|
||||
"""Watch the specified bits from GPIO inputs on the device for changes"""
|
||||
r = remote_hardware_pb2.HardwareMessage()
|
||||
r.typ = remote_hardware_pb2.HardwareMessage.Type.WATCH_GPIOS
|
||||
r.gpio_mask = mask
|
||||
return self.iface.sendData(r, nodeid, portnums_pb2.REMOTE_HARDWARE_APP, wantAck = True) </code></pre>
|
||||
</details>
|
||||
<h3>Methods</h3>
|
||||
<dl>
|
||||
@@ -173,6 +187,23 @@ code for how you can connect to your own custom meshtastic services</p>
|
||||
return self.iface.sendData(r, nodeid, portnums_pb2.REMOTE_HARDWARE_APP, wantAck = True)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.remote_hardware.RemoteHardwareClient.watchGPIOs"><code class="name flex">
|
||||
<span>def <span class="ident">watchGPIOs</span></span>(<span>self, nodeid, mask)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Watch the specified bits from GPIO inputs on the device for changes</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def watchGPIOs(self, nodeid, mask):
|
||||
"""Watch the specified bits from GPIO inputs on the device for changes"""
|
||||
r = remote_hardware_pb2.HardwareMessage()
|
||||
r.typ = remote_hardware_pb2.HardwareMessage.Type.WATCH_GPIOS
|
||||
r.gpio_mask = mask
|
||||
return self.iface.sendData(r, nodeid, portnums_pb2.REMOTE_HARDWARE_APP, wantAck = True) </code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="meshtastic.remote_hardware.RemoteHardwareClient.writeGPIOs"><code class="name flex">
|
||||
<span>def <span class="ident">writeGPIOs</span></span>(<span>self, nodeid, mask, vals)</span>
|
||||
</code></dt>
|
||||
@@ -223,6 +254,7 @@ are 1 will be changed</p></div>
|
||||
<h4><code><a title="meshtastic.remote_hardware.RemoteHardwareClient" href="#meshtastic.remote_hardware.RemoteHardwareClient">RemoteHardwareClient</a></code></h4>
|
||||
<ul class="">
|
||||
<li><code><a title="meshtastic.remote_hardware.RemoteHardwareClient.readGPIOs" href="#meshtastic.remote_hardware.RemoteHardwareClient.readGPIOs">readGPIOs</a></code></li>
|
||||
<li><code><a title="meshtastic.remote_hardware.RemoteHardwareClient.watchGPIOs" href="#meshtastic.remote_hardware.RemoteHardwareClient.watchGPIOs">watchGPIOs</a></code></li>
|
||||
<li><code><a title="meshtastic.remote_hardware.RemoteHardwareClient.writeGPIOs" href="#meshtastic.remote_hardware.RemoteHardwareClient.writeGPIOs">writeGPIOs</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
@@ -614,8 +614,6 @@ class StreamInterface(MeshInterface):
|
||||
"""Write an array of bytes to our stream and flush"""
|
||||
self.stream.write(b)
|
||||
self.stream.flush()
|
||||
while self.stream.out_waiting != 0:
|
||||
time.sleep(0.1) # It seems that on windows flush might return before all bytes actually sent?
|
||||
|
||||
def _readBytes(self, len):
|
||||
"""Read an array of bytes from our stream"""
|
||||
@@ -722,11 +720,11 @@ class SerialInterface(StreamInterface):
|
||||
|
||||
# rts=False Needed to prevent TBEAMs resetting on OSX, because rts is connected to reset
|
||||
self.stream.port = devPath
|
||||
# OS-X seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
|
||||
# OS-X/Windows seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
|
||||
# control and will always drive RTS either high or low (rather than letting the CP102 leave
|
||||
# it as an open-collector floating pin). Since it is going to drive it anyways we want to make
|
||||
# sure it is driven low, so that the TBEAM won't reset
|
||||
if platform.system() == 'Darwin':
|
||||
if platform.system() != 'Linux':
|
||||
self.stream.rts = False
|
||||
self.stream.open()
|
||||
|
||||
@@ -736,7 +734,7 @@ class SerialInterface(StreamInterface):
|
||||
def _disconnected(self):
|
||||
"""We override the superclass implementation to close our port"""
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
if platform.system() != 'Linux':
|
||||
self.stream.rts = True # Return RTS high, so that the reset button still works
|
||||
|
||||
StreamInterface._disconnected(self)
|
||||
|
||||
2
setup.py
2
setup.py
@@ -12,7 +12,7 @@ with open("README.md", "r") as fh:
|
||||
# This call to setup() does all the work
|
||||
setup(
|
||||
name="meshtastic",
|
||||
version="1.1.22",
|
||||
version="1.1.23",
|
||||
description="Python API & client shell for talking to Meshtastic devices",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
|
||||
Reference in New Issue
Block a user