Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recv data is not correct #4

Closed
xzzh999 opened this issue Dec 19, 2018 · 12 comments
Closed

recv data is not correct #4

xzzh999 opened this issue Dec 19, 2018 · 12 comments

Comments

@xzzh999
Copy link

xzzh999 commented Dec 19, 2018

Hi~

when i send follow many times (in hex, no \r\n):

01 01 00 00 00 00 

recv are:

b'\x07\x07\x83\x06\x06\x86'
b'IHII\xc9\xc9'
b'%%\x01!!%'

and the recv code is:

res = await self.ins.read_async(size=AckMsg.ack_size())
print("read data ok!", res)

why?

@xzzh999
Copy link
Author

xzzh999 commented Dec 19, 2018

and sometimes can not recv any data...

@mrjohannchang
Copy link
Owner

Do you have baud and other settings configured correctly?

@xzzh999
Copy link
Author

xzzh999 commented Dec 19, 2018

@changyuheng
yes, i make sure the configure is correct.

self.ins = aioserial.AioSerial(port=self.port, 
                      baudrate=self.baudrate, stopbits=self.stopbit, bytesize=self.databit)

@mrjohannchang
Copy link
Owner

Are you able to get correct information through other terminal applications such as minicom?

@xzzh999
Copy link
Author

xzzh999 commented Dec 20, 2018

yes, i use pyserial-asyncio, it's correct...

@mrjohannchang
Copy link
Owner

Can you please try with pySerial as the APIs of it are more similar with aioserial?
And please also post both code snippets based on pySerial and aioserial and their results here.

@xzzh999
Copy link
Author

xzzh999 commented Dec 20, 2018

I make two serial port COM5 and COM7, and connect them together, i send very simple data to COM5, so COM7 can print the data, the code is very simple, just like as the read me:

self.ins = aioserial.AioSerial(port=self.port, baudrate=self.baudrate, 
     stopbits=self.stopbit, bytesize=self.databit)
 while True:
    print((await self.ins.read_async()).decode(errors='ignore'), end='', flush=True)

just open a port, and keep reading, and use many other serial port tools to send data.

@mrjohannchang
Copy link
Owner

Hi, I see you may be a Chinese. Do you want to talk in Chinese instead? 中文可能比較方便溝通

@xzzh999
Copy link
Author

xzzh999 commented Dec 20, 2018

可以的。
就是我有2根USB串口线互联,分别对应COM5和COM7, 用串口工具测试收发数据,aioserial的发送总是正常的,但是接收是错误的数据。

@mrjohannchang
Copy link
Owner

mrjohannchang commented Dec 20, 2018

Can you please do the same test with both pySerial and aioserial, respectively? Please also post the results of both of the tests here. Because the major difference between pySerial and aioserial are the async feature of the functions provided in aioserial, I hope to see 2 similar test codes and their results side by side. Another reason reason I chose pySerial here for benchmarking is, aioserial pretty much just call the APIs provided by pySerial with an async wrapper, the root cause might be in pySerial.

可以麻煩分別用 pySerialaioserial 做一樣的測試,並把程式碼和結果都在這邊分別列出來嗎?因為 pySerialaioserial 的 API 非常像,差別只在於 aioserial 的 API 是 async,希望您能用相似的測試程式碼分別以二個不同的 library 為基礎做測試,並分別列出結果。選用 pySerial 來做比較除了因為 API 相似外,還因為 aioserial 的所有 API 都是直接以 pySerial 的 API 為基礎,問題很有可能是出在 pySerial 身上。

Test cases:

  1. pySerial send() -> pySerial receive()
  2. pySerial send() -> aioserial receive()
  3. aioserial send() -> pySerial receive()
  4. aioserial send() -> aioserial receive()

@xzzh999
Copy link
Author

xzzh999 commented Dec 21, 2018

ok, i will do that later, for now i must complete my project stuff first..

@mrjohannchang
Copy link
Owner

Any updates @xzzh999?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants