Open Vincent14 opened 7 years ago
To access the uart module you need to use so called IRQs. IRQ is basically simavr implementation of the observer pattern .
So to push a byte to uart you call the pysimavr.swig.simavr.avr_raise_irq method. Something like this might work for simple byte (not tested):
from pysimavr.swig.simavr import avr_raise_irq
import pysimavr.swig.utils as utils
uartInIRQ = avr_io_getirq(avr.backend, utils.AVR_IOCTL_UART_GETIRQ("0") , utils.UART_IRQ_INPUT)
#uartInIRQ = avr.irq.getuart(0, utils.UART_IRQ_INPUT) -- Instead of the above. Only after PR #33 is merged
avr_raise_irq(uartInIRQ, dataByteToSend);
There is a pseudo-code sample with some documentation directly in simavr avr_uart.h source. It seems to get it fully working one also have to wait for XOFF/XON events/IRQs not to overfill the avr's buffer.
edit: Or you can actually use much higher-level api:pysimavr.uart.Uart.send_string. Which you get using the pysimavr.sim.ArduinoSim.get_serial.
I would to send data over the serial port to the simulated Arduino program, how could I do that?
ping @ponty @Premik @SebastianZug (there is some answer without answer!)