Beispiel #1
0
def main(host, port, uid1, uid2, uid3, uid_master):
    ipcon = IPConnection()
    rs4851 = BrickletRS485(uid1, ipcon)
    rs4852 = BrickletRS485(uid2, ipcon)
    rs4853 = BrickletRS485(uid3, ipcon)
    master = BrickMaster(uid_master, ipcon)
    ipcon.connect(host, port)

    while True:
        print('RS485-1: ' + str(rs4851.get_spitfp_error_count()))
        print('RS485-2: ' + str(rs4852.get_spitfp_error_count()))
        print('RS485-3: ' + str(rs4853.get_spitfp_error_count()))
        print('Master-a: ' + str(master.get_spitfp_error_count('a')))
        print('Master-b: ' + str(master.get_spitfp_error_count('b')))
        print('Master-c: ' + str(master.get_spitfp_error_count('c')))
        time.sleep(1)
Beispiel #2
0
def main(host, port, uid):
    ipcon = IPConnection()
    rs485 = BrickletRS485(uid, ipcon)
    ipcon.connect(host, port)

    #    rs485.set_buffer_config(5*1024, 5*1024)
    print(rs485.get_buffer_status())
Beispiel #3
0
def main(host, port, uid):
    ipcon = IPConnection()
    rs485 = BrickletRS485(uid, ipcon)
    ipcon.connect(host, port)

    rs485.set_status_led_config(0)
    rs485.set_error_led_config(0)
    rs485.set_communication_led_config(0)
Beispiel #4
0
def main(host, port, uid_rs485, uid_master):
    ipcon = IPConnection()
    rs485 = BrickletRS485(uid_rs485, ipcon)
    master = BrickMaster(uid_master, ipcon)
    ipcon.connect(host, port)

    print("get:   " + str(rs485.get_bootloader_mode()))
    print("set 1: " + str(rs485.set_bootloader_mode(1)))
Beispiel #5
0
def main(host, port, uid_rs485, uid_master):
    ipcon = IPConnection()
    rs485 = BrickletRS485(uid_rs485, ipcon)
    master = BrickMaster(uid_master, ipcon)
    ipcon.connect(host, port)

    print('Baudrate before: ' + str(master.get_spitfp_baudrate('c')))
    master.set_spitfp_baudrate('c', 2000000)
    print('Baudrate after: ' + str(master.get_spitfp_baudrate('c')))
Beispiel #6
0
def main(host, port, uid):
    ipcon = IPConnection()
    rs485 = BrickletRS485(uid, ipcon)
    ipcon.connect(host, port)

    t = time.time()
    for _ in range(10000):
        rs485.write("1" * 60, 60)

    print(time.time() - t)
Beispiel #7
0
 def connect(self):
     self.ipcon.connect(self.HOST, self.PORT)
     self.ipcon.register_callback(IPConnection.CALLBACK_ENUMERATE,
                                  self.callback)
     self.connected = False
     self.ipcon.enumerate()
     time.sleep(.1)
     if self.connected:
         self.io = BrickletIO16(self.IO16_ID, self.ipcon)
         self.vc = BrickletVoltageCurrent(self.VC_ID, self.ipcon)
         self.rs1 = BrickletRS485(self.RS485_1_ID, self.ipcon)
         self.rs2 = BrickletRS485(self.RS485_2_ID, self.ipcon)
         self.rs485 = [self.rs1, self.rs2]
         self.callbackFn = [self.cb_read_1, self.cb_read_2]
         for i, rs in enumerate(self.rs485):
             rs.set_rs485_configuration(1250000, rs.PARITY_NONE,
                                        rs.STOPBITS_1, rs.WORDLENGTH_8,
                                        rs.DUPLEX_HALF)
             rs.register_callback(rs.CALLBACK_READ, self.callbackFn[i])
             rs.enable_read_callback()
         return True
     else:
         self.ipcon.disconnect()
         return False
Beispiel #8
0
def main(host, port, uid):
    ipcon = IPConnection()
    rs485 = BrickletRS485(uid, ipcon)
    ipcon.connect(host, port)

    t = time.time()
    i = 0
    while True:
        i += 1
        nt = time.time()
        if nt - t >= 1.0:
            print(i)
            i = 0
            t = nt
        rs485.get_chip_temperature()

    print(time.time() - t)
Beispiel #9
0
# and configure the DIP switch on the Bricklet to full-duplex mode

HOST = "localhost"
PORT = 4223
UID = "XYZ" # Change XYZ to the UID of your RS485 Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_rs485 import BrickletRS485

# Callback function for read callback
def cb_read(message):
    print('Message: "' + ''.join(message) + '"')

if __name__ == "__main__":
    ipcon = IPConnection() # Create IP connection
    rs485 = BrickletRS485(UID, ipcon) # Create device object

    ipcon.connect(HOST, PORT) # Connect to brickd
    # Don't use device before ipcon is connected

    # Enable full-duplex mode
    rs485.set_rs485_configuration(115200, rs485.PARITY_NONE, rs485.STOPBITS_1,
                                  rs485.WORDLENGTH_8, rs485.DUPLEX_FULL)

    # Register read callback to function cb_read
    rs485.register_callback(rs485.CALLBACK_READ, cb_read)

    # Enable read callback
    rs485.enable_read_callback()

    # Write "test" string