Closed ghost closed 7 years ago
yeah, the usart driver has both blocking and asynchronous I/O functions ( [ usart_putchar
, usart_getchar
] vs [usart_write_char
, usart_read_char
])
https://github.com/monome/libavr32/blob/master/asf/avr32/drivers/usart/usart.c#L851
is that what you mean?
I've got something cooking here - found an old version of picolisp with none of the crazy preprocessor malarky for building bits of lisp into the rom - just 5 c files. And think I've got the thing more or less working. However if I initialise stdout before I kick off the lisp things blow up (trying to figure out where exactly).
I would like to try defining stdin/stdout using fdevopen, rather than the in-memory stream. See if that works better. However fdevopen seems to not work in an an aleph project, which is confusing me somewhat. Just getting flamed in #avr irc right now trying to figure out what's up.
EDIT: Hang on I'll push the code to my github in case you fancy getting sucked into this white elephant...
https://github.com/rick-monster/aleph-1/tree/picolisp.dirty-worktree loads of weird debug cruft lying around all over the place but yeah it's totally going to work!
EDIT: Incredibly frustrating - I can read & eval 1 and only one lisp expression using the embedded picolisp. all attempts to tame this tiny lisp beast keep blowing up in my face...
There really is an instrinsic problem between monome avr32lib & miniPicoLisp. The reader for miniPL seems to be heavily dependent on 'proper' i/o streams, whereas there seem to be some ways that in-memory stream from avr32lib/asf does not behave the same as stdin/stdout on, e.g desktop linux. The hempl guys seem to get around this by defining proper i/o streams here: https://github.com/simplemachines-italy/hempl/blob/master/src/newlib/devman.c#L119 Can't get my head round their code (doesn't look like it's actually doing anything to stdin/sdout - baffling).
So either:
However... this sucks big time & there performance worries with picolisp! I'm going to look into whether pforth is ready to go or requires this kind of major surgery/hackery. Learning to code in forth might actually turn out less work and definitely more fun!
is it easy to enable regular old blocking stdout/stdin on the serial port? Think this may be the quickest route to start experimenting with miniPicoLisp on aleph...