fix #18 reset button was disabled

ooh this one was super interesting.  I was able to repro from your great description.  The problem was that leaving rts low was disabling the reset button on the board.  So I think the only fix needed was to raise rts high before we close the port.

Meshtastic-python$ bin/run.sh --setstr wifi_ssid "asdf" --debug
rm: cannot remove 'log_*': No such file or directory
DEBUG:root:Connecting to /dev/ttyUSB0
DEBUG:root:Sending: want_config_id: 42

Trigger powerFSM 9
DEBUG:root:Received: {'myInfo': {'myNodeNum': 2883444536, 'hasGps': True, 'numChannels': 13, 'region': 'unset', 'hwModel': 'tbeam', 'firmwareVersion': 'unset', 'packetIdBits': 32, 'currentPacketId': 380285744, 'nodeNumBits': 32, 'messageTimeoutMsec': 300000, 'minAppVersion': 172}}
DEBUG:root:Received: {'radio': {'preferences': {'positionBroadcastSecs': 900, 'sendOwnerInterval': 4, 'waitBluetoothSecs': 120, 'screenOnSecs': 300, 'phoneTimeoutSecs': 900, 'phoneSdsTimeoutSec': 7200, 'meshSdsTimeoutSecs': 7200, 'sdsSecs': 31536000, 'lsSecs': 3601, 'wifiSsid': 'asdf'}, 'channelSettings': {'modemConfig': 'Bw125Cr48Sf4096', 'psk': '1PG7OiApB1nwvP+rz05pvw==', 'name': 'Default'}}}
DEBUG:root:Received: {'nodeInfo': {'num': 2883444536, 'user': {'id': '!2462abdddf38', 'longName': 'Bob b', 'shortName': 'Bb', 'macaddr': 'JGKr3d84'}, 'position': {'batteryLevel': 100, 'time': 315965514}}}
DEBUG:root:Received: {'nodeInfo': {'num': 682754228, 'user': {'id': '!246f28b200b4', 'longName': 'Bob b', 'shortName': 'Bb', 'macaddr': 'JG8osgC0'}, 'position': {'batteryLevel': 79, 'time': 316593914}, 'snr': 9.5}}
DEBUG:root:Received: {'nodeInfo': {'num': 2441803616, 'user': {'id': '!5002918af760', 'longName': 'ryan', 'shortName': 'r', 'macaddr': 'UAKRivdg'}, 'position': {'batteryLevel': 61, 'time': 316497304}, 'snr': 10.0}}
DEBUG:root:Received: {'nodeInfo': {'num': 862631397, 'user': {'id': '!c44f336ab5e5', 'longName': 'Unknown b5e5', 'shortName': '?E5', 'macaddr': 'xE8zarXl'}, 'position': {'time': 1597965319}, 'snr': 13.25}}
DEBUG:root:Received: {'nodeInfo': {'num': 2441803548, 'user': {'id': '!5002918af71c', 'longName': 'Unknown f71c', 'shortName': '?1C', 'macaddr': 'UAKRivcc'}, 'position': {'batteryLevel': 47, 'time': 316494981}, 'snr': 9.5}}
DEBUG:root:Received: {'nodeInfo': {'num': 82599254, 'user': {'id': '!fd1004ec5d56', 'longName': 'Unknown 5d56', 'shortName': '?56', 'macaddr': '/RAE7F1W'}, 'position': {}, 'snr': 9.25}}
DEBUG:root:Received: {'nodeInfo': {'num': 2885173400, 'user': {'id': '!2462abf84098', 'longName': 'Unknown 4098', 'shortName': '?98', 'macaddr': 'JGKr+ECY'}, 'position': {'batteryLevel': 4, 'time': 315966200}, 'snr': 10.75}}
DEBUG:root:Received: {'configCompleteId': 42}
Connected to radio
Setting preference wifi_ssid to asdf
Writing modified preferences to device
DEBUG:root:Sending: set_radio {
  preferences {
    position_broadcast_secs: 900
    send_owner_interval: 4
    wait_bluetooth_secs: 120
    screen_on_secs: 300
    phone_timeout_secs: 900
    phone_sds_timeout_sec: 7200
    mesh_sds_timeout_secs: 7200
    sds_secs: 31536000
    ls_secs: 3601
    wifi_ssid: "asdf"
  }
  channel_settings {
    modem_config: Bw125Cr48Sf4096
    psk: "\324\361\273: )\007Y\360\274\377\253\317Ni\277"
    name: "Default"
  }
}

DEBUG:root:Closing serial stream
DEBUG:root:reader is exiting
This commit is contained in:
geeksville
2020-09-16 09:39:45 -07:00
parent 864cd4773c
commit 8c86a49b63

View File

@@ -437,9 +437,16 @@ class StreamInterface(MeshInterface):
self.devPath = devPath
self._rxBuf = bytes() # empty
self._wantExit = False
# Note: we provide None for port here, because we will be opening it later
self.stream = serial.Serial(
devPath, 921600, exclusive=True, timeout=0.5)
self.stream.setRTS(False)
None, 921600, exclusive=True, timeout=0.5)
# rts=False Needed to prevent TBEAMs resetting on OSX, because rts is connected to reset
self.stream.port = devPath
self.stream.rts = False
self.stream.open()
self._rxThread = threading.Thread(target=self.__reader, args=())
MeshInterface.__init__(self, debugOut=debugOut, noProto=noProto)
@@ -528,8 +535,9 @@ class StreamInterface(MeshInterface):
pass
except serial.SerialException as ex:
logging.warn(
"Meshtastic erial port disconnected, disconnecting...")
f"Meshtastic serial port disconnected, disconnecting... {ex}")
finally:
logging.debug("reader is exiting")
self.stream.rts = True # Return RTS high, so that the reset button still works
self.stream.close()
self._disconnected()