Skip to content

Commit

Permalink
Discard master/slave vocabulary
Browse files Browse the repository at this point in the history
  • Loading branch information
bopopescu committed Jul 19, 2020
1 parent 07514d2 commit 48c7a79
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 83 deletions.
20 changes: 10 additions & 10 deletions Examples/Doc-GettingStarted-Yocto-RS485/helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
if serialPort is None:
sys.exit('No module connected (check cable)')

print("Please enter the MODBUS slave address (1...255)")
slave = 0
while (slave < 1) or (slave > 255):
slave = int(input("slave: ")) # use raw_input in python 2.x
print("Please enter the MODBUS subordinate address (1...255)")
subordinate = 0
while (subordinate < 1) or (subordinate > 255):
subordinate = int(input("subordinate: ")) # use raw_input in python 2.x

reg = 0
while (reg < 1) or (reg >= 50000) or (reg % 10000) == 0:
Expand All @@ -49,13 +49,13 @@

while serialPort.isOnline():
if reg >= 40001:
val = serialPort.modbusReadRegisters(slave, reg - 40001, 1)[0]
val = serialPort.modbusReadRegisters(subordinate, reg - 40001, 1)[0]
elif reg >= 30001:
val = serialPort.modbusReadInputRegisters(slave, reg - 30001, 1)[0]
val = serialPort.modbusReadInputRegisters(subordinate, reg - 30001, 1)[0]
elif reg >= 10001:
val = serialPort.modbusReadInputBits(slave, reg - 10001, 1)[0]
val = serialPort.modbusReadInputBits(subordinate, reg - 10001, 1)[0]
else:
val = serialPort.modbusReadBits(slave, reg - 1, 1)[0]
val = serialPort.modbusReadBits(subordinate, reg - 1, 1)[0]

print("Current value: " + str(val))
print("Press ENTER to read again, Q to quit")
Expand All @@ -69,7 +69,7 @@
if cmd != "" and ((reg % 30000) < 10000):
val = int(cmd)
if reg >= 30001:
serialPort.modbusWriteRegister(slave, reg - 30001, val)
serialPort.modbusWriteRegister(subordinate, reg - 30001, val)
else:
serialPort.modbusWriteBit(slave, reg - 1, val)
serialPort.modbusWriteBit(subordinate, reg - 1, val)
YAPI.FreeAPI()
20 changes: 10 additions & 10 deletions Examples/Prog-Modbus/modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
if serialPort is None:
sys.exit('No module connected (check cable)')

print("Please enter the MODBUS slave address (1...255)")
slave = 0
while (slave < 1) or (slave > 255):
slave = int(input("slave: ")) # use raw_input in python 2.x
print("Please enter the MODBUS subordinate address (1...255)")
subordinate = 0
while (subordinate < 1) or (subordinate > 255):
subordinate = int(input("subordinate: ")) # use raw_input in python 2.x

reg = 0
while (reg < 1) or (reg >= 50000) or (reg % 10000) == 0:
Expand All @@ -35,13 +35,13 @@

while True:
if reg >= 40001:
val = serialPort.modbusReadInputRegisters(slave, reg - 40001, 1)[0]
val = serialPort.modbusReadInputRegisters(subordinate, reg - 40001, 1)[0]
elif reg >= 30001:
val = serialPort.modbusReadRegisters(slave, reg - 30001, 1)[0]
val = serialPort.modbusReadRegisters(subordinate, reg - 30001, 1)[0]
elif reg >= 10001:
val = serialPort.modbusReadInputBits(slave, reg - 10001, 1)[0]
val = serialPort.modbusReadInputBits(subordinate, reg - 10001, 1)[0]
else:
val = serialPort.modbusReadBits(slave, reg - 1, 1)[0]
val = serialPort.modbusReadBits(subordinate, reg - 1, 1)[0]

print("Current value: " + str(val))
print("Press ENTER to read again, Q to quit")
Expand All @@ -54,6 +54,6 @@
if cmd != "" and ((reg % 30000) < 10000):
val = int(cmd)
if reg >= 30001:
serialPort.modbusWriteRegister(slave, reg - 30001, val)
serialPort.modbusWriteRegister(subordinate, reg - 30001, val)
else:
serialPort.modbusWriteBit(slave, reg - 1, val)
serialPort.modbusWriteBit(subordinate, reg - 1, val)
30 changes: 15 additions & 15 deletions Sources/yocto_hubport.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#noinspection PyProtectedMember
class YHubPort(YFunction):
"""
The YHubPort class provides control over the power supply for slave ports
The YHubPort class provides control over the power supply for subordinate ports
on a YoctoHub. It provide information about the device connected to it.
The logical name of a YHubPort is always automatically set to the
unique serial number of the Yoctopuce device connected to it.
Expand Down Expand Up @@ -160,7 +160,7 @@ def get_baudRate(self):
@staticmethod
def FindHubPort(func):
"""
Retrieves a YoctoHub slave port for a given identifier.
Retrieves a YoctoHub subordinate port for a given identifier.
The identifier can be specified using several formats:
<ul>
<li>FunctionLogicalName</li>
Expand All @@ -170,22 +170,22 @@ def FindHubPort(func):
<li>ModuleLogicalName.FunctionLogicalName</li>
</ul>
This function does not require that the YoctoHub slave port is online at the time
This function does not require that the YoctoHub subordinate port is online at the time
it is invoked. The returned object is nevertheless valid.
Use the method YHubPort.isOnline() to test if the YoctoHub slave port is
Use the method YHubPort.isOnline() to test if the YoctoHub subordinate port is
indeed online at a given time. In case of ambiguity when looking for
a YoctoHub slave port by logical name, no error is notified: the first instance
a YoctoHub subordinate port by logical name, no error is notified: the first instance
found is returned. The search is performed first by hardware name,
then by logical name.
If a call to this object's is_online() method returns FALSE although
you are certain that the matching device is plugged, make sure that you did
call registerHub() at application initialization time.
@param func : a string that uniquely characterizes the YoctoHub slave port, for instance
@param func : a string that uniquely characterizes the YoctoHub subordinate port, for instance
YHUBETH1.hubPort1.
@return a YHubPort object allowing you to drive the YoctoHub slave port.
@return a YHubPort object allowing you to drive the YoctoHub subordinate port.
"""
# obj
obj = YFunction._FindFromCache("HubPort", func)
Expand All @@ -196,14 +196,14 @@ def FindHubPort(func):

def nextHubPort(self):
"""
Continues the enumeration of YoctoHub slave ports started using yFirstHubPort().
Caution: You can't make any assumption about the returned YoctoHub slave ports order.
If you want to find a specific a YoctoHub slave port, use HubPort.findHubPort()
Continues the enumeration of YoctoHub subordinate ports started using yFirstHubPort().
Caution: You can't make any assumption about the returned YoctoHub subordinate ports order.
If you want to find a specific a YoctoHub subordinate port, use HubPort.findHubPort()
and a hardwareID or a logical name.
@return a pointer to a YHubPort object, corresponding to
a YoctoHub slave port currently online, or a None pointer
if there are no more YoctoHub slave ports to enumerate.
a YoctoHub subordinate port currently online, or a None pointer
if there are no more YoctoHub subordinate ports to enumerate.
"""
hwidRef = YRefParam()
if YAPI.YISERR(self._nextFunction(hwidRef)):
Expand All @@ -219,12 +219,12 @@ def nextHubPort(self):
@staticmethod
def FirstHubPort():
"""
Starts the enumeration of YoctoHub slave ports currently accessible.
Starts the enumeration of YoctoHub subordinate ports currently accessible.
Use the method YHubPort.nextHubPort() to iterate on
next YoctoHub slave ports.
next YoctoHub subordinate ports.
@return a pointer to a YHubPort object, corresponding to
the first YoctoHub slave port currently online, or a None pointer
the first YoctoHub subordinate port currently online, or a None pointer
if there are none.
"""
devRef = YRefParam()
Expand Down
28 changes: 14 additions & 14 deletions Sources/yocto_i2cport.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,12 @@ def reset(self):

return self.sendCommand("Z")

def i2cSendBin(self, slaveAddr, buff):
def i2cSendBin(self, subordinateAddr, buff):
"""
Sends a one-way message (provided as a a binary buffer) to a device on the I2C bus.
This function checks and reports communication errors on the I2C bus.
@param slaveAddr : the 7-bit address of the slave device (without the direction bit)
@param subordinateAddr : the 7-bit address of the subordinate device (without the direction bit)
@param buff : the binary buffer to be sent
@return YAPI.SUCCESS if the call succeeds.
Expand All @@ -724,7 +724,7 @@ def i2cSendBin(self, slaveAddr, buff):
# val
# msg
# reply
msg = "@" + ("%02x" % slaveAddr) + ":"
msg = "@" + ("%02x" % subordinateAddr) + ":"
nBytes = len(buff)
idx = 0
while idx < nBytes:
Expand All @@ -746,12 +746,12 @@ def i2cSendBin(self, slaveAddr, buff):
return YAPI.IO_ERROR
return YAPI.SUCCESS

def i2cSendArray(self, slaveAddr, values):
def i2cSendArray(self, subordinateAddr, values):
"""
Sends a one-way message (provided as a list of integer) to a device on the I2C bus.
This function checks and reports communication errors on the I2C bus.
@param slaveAddr : the 7-bit address of the slave device (without the direction bit)
@param subordinateAddr : the 7-bit address of the subordinate device (without the direction bit)
@param values : a list of data bytes to be sent
@return YAPI.SUCCESS if the call succeeds.
Expand All @@ -763,7 +763,7 @@ def i2cSendArray(self, slaveAddr, values):
# val
# msg
# reply
msg = "@" + ("%02x" % slaveAddr) + ":"
msg = "@" + ("%02x" % subordinateAddr) + ":"
nBytes = len(values)
idx = 0
while idx < nBytes:
Expand All @@ -785,17 +785,17 @@ def i2cSendArray(self, slaveAddr, values):
return YAPI.IO_ERROR
return YAPI.SUCCESS

def i2cSendAndReceiveBin(self, slaveAddr, buff, rcvCount):
def i2cSendAndReceiveBin(self, subordinateAddr, buff, rcvCount):
"""
Sends a one-way message (provided as a a binary buffer) to a device on the I2C bus,
then read back the specified number of bytes from device.
This function checks and reports communication errors on the I2C bus.
@param slaveAddr : the 7-bit address of the slave device (without the direction bit)
@param subordinateAddr : the 7-bit address of the subordinate device (without the direction bit)
@param buff : the binary buffer to be sent
@param rcvCount : the number of bytes to receive once the data bytes are sent
@return a list of bytes with the data received from slave device.
@return a list of bytes with the data received from subordinate device.
On failure, throws an exception or returns an empty binary buffer.
"""
Expand All @@ -805,7 +805,7 @@ def i2cSendAndReceiveBin(self, slaveAddr, buff, rcvCount):
# msg
# reply
# rcvbytes
msg = "@" + ("%02x" % slaveAddr) + ":"
msg = "@" + ("%02x" % subordinateAddr) + ":"
nBytes = len(buff)
idx = 0
while idx < nBytes:
Expand Down Expand Up @@ -834,17 +834,17 @@ def i2cSendAndReceiveBin(self, slaveAddr, buff, rcvCount):
rcvbytes = YAPI._hexStrToBin(reply)
return rcvbytes

def i2cSendAndReceiveArray(self, slaveAddr, values, rcvCount):
def i2cSendAndReceiveArray(self, subordinateAddr, values, rcvCount):
"""
Sends a one-way message (provided as a list of integer) to a device on the I2C bus,
then read back the specified number of bytes from device.
This function checks and reports communication errors on the I2C bus.
@param slaveAddr : the 7-bit address of the slave device (without the direction bit)
@param subordinateAddr : the 7-bit address of the subordinate device (without the direction bit)
@param values : a list of data bytes to be sent
@param rcvCount : the number of bytes to receive once the data bytes are sent
@return a list of bytes with the data received from slave device.
@return a list of bytes with the data received from subordinate device.
On failure, throws an exception or returns an empty array.
"""
Expand All @@ -855,7 +855,7 @@ def i2cSendAndReceiveArray(self, slaveAddr, values, rcvCount):
# reply
# rcvbytes
res = []
msg = "@" + ("%02x" % slaveAddr) + ":"
msg = "@" + ("%02x" % subordinateAddr) + ":"
nBytes = len(values)
idx = 0
while idx < nBytes:
Expand Down
Loading

0 comments on commit 48c7a79

Please sign in to comment.