MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / __init__

Method __init__

src/ext/makerbot_pyserial/rfc2217.py:882–915  ·  view source on GitHub ↗
(self, serial_port, connection, logger=None)

Source from the content-addressed store, hash-verified

880 a (thread safe) write function, that writes the string to the network."""
881
882 def __init__(self, serial_port, connection, logger=None):
883 self.serial = serial_port
884 self.connection = connection
885 self.logger = logger
886 self._client_is_rfc2217 = False
887
888 # filter state machine
889 self.mode = M_NORMAL
890 self.suboption = None
891 self.telnet_command = None
892
893 # states for modem/line control events
894 self.modemstate_mask = 255
895 self.last_modemstate = None
896 self.linstate_mask = 0
897
898 # all supported telnet options
899 self._telnet_options = [
900 TelnetOption(self, 'ECHO', ECHO, WILL, WONT, DO, DONT, REQUESTED),
901 TelnetOption(self, 'we-SGA', SGA, WILL, WONT, DO, DONT, REQUESTED),
902 TelnetOption(self, 'they-SGA', SGA, DO, DONT, WILL, WONT, INACTIVE),
903 TelnetOption(self, 'we-BINARY', BINARY, WILL, WONT, DO, DONT, INACTIVE),
904 TelnetOption(self, 'they-BINARY', BINARY, DO, DONT, WILL, WONT, REQUESTED),
905 TelnetOption(self, 'we-RFC2217', COM_PORT_OPTION, WILL, WONT, DO, DONT, REQUESTED, self._client_ok),
906 TelnetOption(self, 'they-RFC2217', COM_PORT_OPTION, DO, DONT, WILL, WONT, INACTIVE, self._client_ok),
907 ]
908
909 # negotiate Telnet/RFC2217 -> send initial requests
910 if self.logger:
911 self.logger.debug("requesting initial Telnet/RFC 2217 options")
912 for option in self._telnet_options:
913 if option.state is REQUESTED:
914 self.telnetSendOption(option.send_yes, option.option)
915 # issue 1st modem state notification
916
917 def _client_ok(self):
918 """callback of telnet option. it gets called when option is activated.

Callers

nothing calls this directly

Calls 2

telnetSendOptionMethod · 0.95
TelnetOptionClass · 0.85

Tested by

no test coverage detected