Reverse a string

Alright, next let’s make the server more interesting by having it respond to the client with thereverse of the text that they sent. The server will respond to the client every time they press theENTER key. Each server response will be in a new line.

This time you’ll need a buffer; you can use heapless::Vec. Here’s the starter code:

  1. #![deny(unsafe_code)]
  2. #![no_main]
  3. #![no_std]
  4. #[allow(unused_imports)]
  5. use aux11::{entry, iprint, iprintln};
  6. use heapless::{consts, Vec};
  7. #[entry]
  8. fn main() -> ! {
  9. let (usart1, mono_timer, itm) = aux11::init();
  10. // A buffer with 32 bytes of capacity
  11. let mut buffer: Vec<u8, consts::U32> = Vec::new();
  12. loop {
  13. buffer.clear();
  14. // TODO Receive a user request. Each user request ends with ENTER
  15. // NOTE `buffer.push` returns a `Result`. Handle the error by responding
  16. // with an error message.
  17. // TODO Send back the reversed string
  18. }
  19. }