Ejemplo n.º 1
0
 def __init__(self, parent=None):
     QDialog.__init__(self, parent)
     self.setWindowTitle('myGUI')
     self.resize(600, 400)
     self.tNow = 0
     self.data = [[], [], [], []]
     self.create_main_frame()
     self.ser = mySerial.mySerial()
     print('Start!!!\r\n')
Ejemplo n.º 2
0
 def __init__(self, serNum=None,bandrate=None):
     #self.Serial_name = rospy.get_param("GPSport_name",'/dev/ttyUSB1')
     self.Serial_name = "/dev/ttyUSB1"
     self.Serial_baudrate = rospy.get_param("GPSport_baudrate","115200")
     self.serial = mySerial.mySerial()
     self.serial.openSerial(self.Serial_name, int(self.Serial_baudrate))
     print "GPS serial "+self.Serial_name+" open"
     
     self.Data_Valid_Flag = 0
     self.E_POSITION = 0.0
     self.N_POSITION = 0.0
     self.YAW_POSITION = 0.0
Ejemplo n.º 3
0
 def createPort(self):
     ''' (self) -> None
     
         Создание переменных для работы с портом.
     '''
     self.setupCOM = mySerial.mySerial(parent=self, port='COM2')
     self.setupCOM.setWindowTitle(u'Настройка порта')
     
     # сделаем окно модальным
     # + в данном случае виджет должен иметь предка self !!!
     self.setupCOM.setWindowModality(QtCore.Qt.WindowModal)
     self.connect(self.setupCOM,
                  QtCore.SIGNAL("readData(PyQt_PyObject, PyQt_PyObject,\
                  PyQt_PyObject)"),
                  self.protocol)
Ejemplo n.º 4
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        
        # para criar a GUI temos que chamar o metodo setupUi
        self.setupUi(self)
        
        self.setWindowTitle('Main designer GUI')
        self.resize(600, 200)
        self.timer = QTimer()
        self.timer.timeout.connect(self.timer_tick)
        self.timer.start(100) 

        self.chkLED.setChecked(False)
        self.connect(self.chkLED, SIGNAL('stateChanged(int)'), self.on_chkLED)
        self.butSend.clicked.connect(self.on_butSend)
                 
        self.ser = mySerial.mySerial()
Ejemplo n.º 5
0
	def __init__(self):

		self.mSerial = mySerial()  #初始化串口

		'''----------------------------指令帧----------------------------------------------------------'''
		self.commandFramehHeader1 = "0xEB" 	#帧头
		self.commandFramehHeader2 = "0x90"	#帧头
		self.commandHandId = "0x01"			#灵巧手的ID号(1-254)默认为1 , 广播ID为255
		self.commandDataLength = "0x02" 	#数据体的长度:数据体长度 + 校验和的长度
		self.commandData1 = ""				#数据体(指令号)1	
		self.commandData2 = ""				#数据体(指令号)2
		self.commandCheckSum = ""			#校验和
		'''----------------------------应答帧----------------------------------------------------------'''
		self.replyFramehHeader1 = "0xEE" 	#帧头
		self.replyFramehHeader2 = "0x16"	#帧头
		self.replyHandId = "0x01"			#灵巧手的ID号(1-254)默认为1 , 广播ID为255
		self.replyDataLength = "0x02" 		#数据体的长度:数据体长度 + 校验和的长度
		self.replyCmdData = ""				#返回发送的命令号	
		self.replyData = ""					#数据体
		self.replyCheckSum = ""				#校验和

		'''---------------------------指令类型-----------------------------------------------------------'''
		self.CMD_MC_SET_DRVALL_SEEKANGLE_GYH 		= "0x54" 				#设置目标归一化角度
		self.CMD_MC_SET_DRVALL_SEEKPOS 				= "0x50"				#设置目标位置
		self.CMD_MC_SET_DRVALL_SPEED 				= "0x51"				#设置速度
		self.CMD_MC_SET_DRVALL_YBP_THRESHOLD 		= "0x52"				#设置抓力阈值
		self.CMD_MC_READ_DRVALL_SEEKGYHANGLE		= "0xD7"				#读取目标归一化角度
		self.CMD_MC_READ_DRVALL_SEEKPOS 			= "0xD0"				#读取目标位置
		self.CMD_MC_READ_DRVALL_CURANGLE_GYH 		= "0xD9"				#读取当前归一化角度
		self.CMD_MC_READ_DRVALL_CURPOS				= "0xD1"				#读取当前位置
		self.CMD_MC_READ_DRVALL_SPEED 				= "0xD2"				#读取当前速度
		self.CMD_MC_READ_DRVALL_YBP_THRESHOLD 		= "0xD3"				#读取抓力阈值
		self.CMD_MC_READ_DRVALL_YBP_RAWDATA			= "0xD4"				#读取传感器原始值
		self.CMD_MC_PARA_SAVE						= "0x01"				#参数固化,掉电不丢失
		self.CMD_MC_PARA_ID_SET 					= "0x04"				#设置灵巧手ID号
		self.CMD_MC_MOVE_K_SET_CURPOS_IN_CMAP		= "0x05"				#保存当前手势到手势序列K中
		self.CMD_MC_MOVE_K_SHOW 					= "0x06"				#将手势序列K中的手势展示
		self.CMD_MC_MOVE_K_SHOW_ASDEFAULT			= "0x07"				#将当前手势保存为上电默认状态
Ejemplo n.º 6
0
print 'Send first information'
print (myserial.receive())
#sleep(8)
myserial.send('#@200300654456+666-999$')
print (myserial.receive())
#sleep(8)
myserial.send('#8200200654456+200-200$')
print (myserial.receive())
#sleep(8)
myserial.send('#a200300200200+666-999$')
print (myserial.receive())
#sleep(8)
myserial.closePort()
'''
#Serial Initialization
myserial = mySerial.mySerial('/dev/ttyUSB0', 9600)


#Imaging Processing



#Sound Processing


#Main A infinite loop
while True:
	os.cmd('') # System Command
	[isFinished,x,y] = readFile.readFile()
	if isFinished == True:
	    break
Ejemplo n.º 7
0
try:
    # read all the data from the file
    data = file.read()
finally:
    file.close()

#check the data length by the file size
if not len(data) == file_size:
    print("data length error")

# you need to convert the bytes to bytearray because that the bytes can no be altered
data = bytearray(data)

# init the serial port
mySer = mySerial(57600, serial_com)

# open the serial port
mySer.open()

boot_head_ack = False

try:
    # transfer the data to the stm8 via the serial port
    # set the serial operation non-block
    mySer.ser.timeout = 0.5
    #1: send the head and wait for the ack (block operation)
    while boot_head_ack == False:
        mySer.write(BOOT_HEAD)

        #2: recv the head ack ok