Read and write command with python project on relay

I follow relay's command set "@00 RS 0" to get returns status of all relays.In arduino serial monitor tool,I send the command and manage to get proper reply message eg: #01 1.

In my python project,I expect write command of "@00 RS 0" to serial port of relays should return same message. However,it doesn't.

I execute the method ConnectFunc() 3 times,get return difference message as follow.I'm lose with the message.What suppose to do to make it reply message same as arduino serial monitor.

('read data', '011617292515111916\r#0 98 0 019 918 1\r\n')
('read data', '1 9183171715\r#0 8 7 51113191815#0119181611 8 1 787\r#0 617151113191815\n')
('read data', ' 1 151871 8219\n')

def ConnectFunc(self):
            print("Connect function")
            global Arduino
            global DeviceAddress
            try:


                Arduino = serial.Serial(self.PortNumberEntry.get(), self.BaudOptionVar.get(), timeout=.1)
                #tkMessageBox.showinfo("Arduino COnnection", "Successfully connected")
                DeviceAddress = self.AddressEntry.get()
                print('Device address: %s' % DeviceAddress)
                global thread
                thread = SerialThread(self.queue)
                print('Starting thread')
                thread.start()

                Arduino.write("@00 RS 0\r")
                time.sleep(6)
                data = Arduino.readline()
                print("read data",data)

            except SerialException:
                Arduino.close()
                #tkMessageBox.showerror("Error", " Erorr in opening port")
                #return

Thank your advice

I think you are opening the Serial connection for each communication with the Arduino. If so don't. Keep the serial port open until you are completely finished with the Arduino.

You may find some ideas in this Python - Arduino demo

...R

Robin2:
I think you are opening the Serial connection for each communication with the Arduino. If so don’t. Keep the serial port open until you are completely finished with the Arduino.

You may find some ideas in this Python - Arduino demo

…R

Actually I open serial connection once and set serial.serial as Arduino globally in the program,the keep use Arduino until the program closed.
I just copy one of the method of the program to explain the issue I facing.
Thank your reply

willielou:
I just copy one of the method of the program to explain the issue I facing.

Then I guess the problem is in the part you did not post.

…R

I've solved the issue with follow

text = Arduino.readline().decode()