Beispiel #1
0
 def connect_to_controller(self):
     global ser
     if ser.is_open:
         print("Already connected.")
         return
     else:
         print('Attempting to connect...')
         result = sc.serial_ports()
         print(result)
         port = sc.ping_controller(result)
         if port == -1:
             print('Connection failed')
             self.connection_status_label.config(
                 fg="red", text="Not connected. (attempt failed)")
             return -1
         else:
             ser.port = port
             ser.open()
     if ser.is_open:
         print('Connected at ' + port)
         self.connection_status_label.config(fg="green", text="Connected")
         return 0
     else:
         print('Connection failed')
         self.connection_status_label.config(
             fg="red", text="Not connected. (attempt failed)")
         return -1
Beispiel #2
0
 def ConnectToDevice(self, ports=sc.serial_ports()):
     super().ConnectToDevice(ports=ports,
                             defPort='/dev/ttyUSB1',
                             baud=19200,
                             qrymsg=diaquerybytes,
                             retmsg='00' + dia60mLsyringe,
                             trycount=11,
                             readsequence=ETXbyte)
Beispiel #3
0
 def Setup(self, ports=sc.serial_ports()):
     print('Setup() SyringePumpManager')
     for p in ports:
         print('remaining port at syr_ma Setup(): ', p)
     self.ConnectToDevice(ports)
     for p in self.Pumps:
         if not self.PumpIsTalking(p):
             print('pump with communication issues: ' + p.name)
             if not self.PumpIsTalking(p):
                 print('issues are persistent')
             else:
                 print('issues were resolved')
Beispiel #4
0
 def ConnectToDevice(self, ports=sc.serial_ports()):
     p = super().ConnectToDevice(defPort='/dev/ttyACM0',
                                 ports=ports,
                                 trycount=11,
                                 baud=9600,
                                 retmsg='ok')
     #self.ser.timeout = 11
     #self.SendCommand('ping')
     #self.ser.write(b'get')
     #print('get response: ' + self.ser.readline().decode().rstrip())
     self.ser.readlines()
     self.ser.flushInput()
     return p
Beispiel #5
0
 def ConnectToDevice(self,
                     defPort=None,
                     baud=9600,
                     qrymsg=b'ping',
                     retmsg='pong',
                     trycount=1,
                     ports=sc.serial_ports(),
                     readsequence='\n'):
     if self.emulator_mode:
         print('starting in emulator mode')
     elif self.ser.is_open:
         print('already connected')
     else:
         print('attempting to connect to Device: %s' % self.name)
         s = sc.ping_controller(defPort, ports, baud, qrymsg, retmsg,
                                trycount, readsequence)
         self.ser.port = s
         self.ser.baudrate = baud
         self.ser.open()
         self.connection_status = 'connected'
         return s
 def SetupSerialIO(self):
     ports = s_c.serial_ports()
     if (self.cnc_ma):
         #don't test ports again once they're known
         portToRemove = self.cnc_ma.ConnectToDevice(ports)
         print('removing port: ' + str(portToRemove))
         ports.remove(portToRemove)
         self.cnc_ma.SetInitialState()
         self.cnc_ma.SetPosition(PositionsDict['NeutralB'])
         if (self.ra_ma):
             portToRemove = self.ra_ma.ConnectToDevice(ports)
             print('removing port: ' + str(portToRemove))
             ports.remove(portToRemove)
         if (self.syr_ma):
             for p in ports:
                 print('remaining port at syr_ma: ', p)
             self.syr_ma.Setup(ports)
         time.sleep(1.1)
         #do this twice to position robo arm?
         self.SetPosition(PositionsDict['NeutralB'])
         time.sleep(1.1)
         self.SetPosition(PositionsDict['NeutralA'])
 def ConnectToDevice(self,ports = sc.serial_ports()):
     return super().ConnectToDevice(defPort='/dev/ttyUSB0',
     ports=ports, baud=115200, retmsg='echo:start')