I'm sorry, I think you are mistaking me for someone else. Unlike that person I do have some experience of serial communications on both the software and hardware side. What I don't have is a lot of experience using SimulIDE - in fact I am completely new to it. I need your help understanding how SimulIDE works, how to interpret what I'm seeing, and figuring out why it's behaving how it does. I don't think I need any help writing Python software that sends and receives serial data, configuring virtual serial ports or testing that this combination behaves how it should. The problems I'm having - whether the consequence of my inexperience, a confusing UI, AVR misconfiguration or an actual bug in SimulIDE - start and end inside SimulIDE.
arcachofo wrote:Any application using serial always send raw bytes, in this case it sends the ASCII code of a character as a raw byte. It doesn't matter if you enter the value directly or you enter a character.
Minicom is a terminal emulator and as such mainly deals with sending and receiving encoded
characters.
It falls well short if you want to send the hex value 0x84, or binary 1011 1011, and does not know what to do when receiving non-ASCII/ANSI/VT-whatever data. Terminal emulators are intended for human <> machine and human <> human communication and are not really suitable for debugging machine <> machine communication, where much of the data cannot reasonably be encoded to printable characters. I know this because I have been using terminal emulators like Minicom since 1989. Python by contrast is great for debugging machine <> machine serial communication, since it makes it easy to convert between hex/binary/ASCII/UTF-8 and further process the data, whether for display or computation.
arcachofo wrote:Anyway I tested with another program sending raw values, but that is just irrelevant.
Here we are in complete agreement.
arcachofo wrote:And all the tests I do are working correctly.
I don't see how any test other than running my simulation would prove anything.
arcachofo wrote:It is also weird that you are sending 7 bytes and receiving only 5.
Yes. Yes it is. Maybe I should ask a question in the forum about what might be causing this...
arcachofo wrote:Did you test by connecting to a serial terminal and sending data manually?
I understand you like using text terminal software for this, and that's ok, to each their own. Yes, as I've stated previously I did try sending ASCII data and it did show up correctly in the serial port's serial monitor. I've just checked now though, and it is garbled in the AVR's serial monitor.
- Code:
import serial
port = serial.Serial("/tmp/ptyIN")
port.baudrate = 9600
port.bytesize = 8
port.parity = serial.PARITY_NONE
port.stopbits = 1
msg = "Hello World!"
port.write(msg.encode("ascii"))
Of course, but I saw no reason to waste time on it, because it's both incorrect and beside the point. The problem I'm having is not related to sending data to SimulIDE, I already confirmed that this works and told you about it earlier in the thread:
Lomax wrote:If I send an ASCII string to SimulIDE from Python it appears correctly in the serial monitor
Writing this made me look again though, and I may have made a mistake in watching only the AVR's serial monitor, because I can see that the correct values are appearing in the serial port's serial monitor - but they are still incorrect in the AVR's serial monitor:
- Code:
import serial
port = serial.Serial("/tmp/ptyIN")
port.baudrate = 9600
port.bytesize = 8
port.parity = serial.PARITY_NONE
port.stopbits = 1
msg = bytearray([0x01,0x03,0x00,0x00,0x00,0x01,0x84])
port.write(msg)
Maybe this observation will allow us to make progress?