MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / set_port

Method set_port

Software/Python/easysensors.py:226–258  ·  view source on GitHub ↗

Sets the port that's going to be used by our new device. Again, we can't communicate with our device, because the class doesn't have any methods for interfacing with it, so we need to create a derived class that does this. :param str port: The port we're connecting

(self, port)

Source from the content-addressed store, hash-verified

224 return self.pin
225
226 def set_port(self, port):
227 """
228 Sets the port that's going to be used by our new device. Again, we can't communicate with our
229 device, because the class doesn't have any methods for interfacing with it, so we need to create
230 a derived class that does this.
231
232 :param str port: The port we're connecting the device to. Take a look at the :ref:`hardware-ports-section`' locations.
233
234 Apart from this graphical representation of the ports' locations (:ref:`hardware-ports-section` locations),
235 take a look at the list of ports in :py:meth:`~easysensors.Sensor.__init__`'s description.
236
237 """
238 debug(port)
239 self.port = port
240 debug(self.port)
241 debug("self.gpg is {}".format(self.gpg))
242
243 if port == "AD1":
244 self.portID = self.gpg.GROVE_1
245 elif port == "AD2":
246 self.portID = self.gpg.GROVE_2
247 elif port == "SERIAL":
248 self.portID = -1
249 elif port == "I2C":
250 self.portID = -2
251 elif port == "SERVO1":
252 self.portID = self.gpg.SERVO_1
253 elif port == "SERVO2":
254 self.portID = self.gpg.SERVO_2
255 else:
256 self.portID = -5
257
258 debug(self.portID)
259
260 def get_port(self):
261 """

Callers 1

__init__Method · 0.95

Calls 1

debugFunction · 0.70

Tested by

no test coverage detected