0

all I am new to Embedded development. Currently, I am working on the discovery board using the discovery book. I have almost completed the book now I want to achieve more in this. What do I want to do? I recently worked on sensors, I got the reading from the sensors on the itmdump(itm.txt) file. Now I want this data to post on an (HTTP request). My plan??

  1. Write the data into a file.
  2. Get data from that file.
  3. Post data to the provided link.

I am working with a no_std environment and found nothing on how to output the data into a file directly or from itmdump to a file. This is my repo I want to write this hello discovery into a file. Can anyone please help me with how can I achieve this? and am I going right with the steps to achieve my task?

The no_std code:

#![no_main]
#![no_std]


use cortex_m_rt::entry;
use cortex_m::iprintln;
use panic_itm as _;
use stm32f3_discovery::stm32f3xx_hal::prelude::*;

#[entry()]
fn main() -> !{

    let peripherals = cortex_m::Peripherals::take().unwrap();
    let mut itm = peripherals.ITM;


    iprintln!(&mut itm.stim[0],"Hello Discovery!");

    loop {

    }
}
  • Hello, I not have experience with no_std but i think tht'a the standard librariy should be work. Could you try fs::write("itm.txt", b"Lorem ipsum")?; https://doc.rust-lang.org/std/fs/fn.write.html? – Zeppi Aug 12 '21 at 09:51
  • no it's giving **error error[E0432]: unresolved import `std`** –  Aug 12 '21 at 10:08
  • Are you wanting to write `itm.txt` on the STM32? Because with the info provide: microcontrollers don't have discs to write to and connecting to the internet requires a networking chip – Tarick Welling Aug 12 '21 at 11:02
  • @TarickWelling my task is to post the readings of sensors to a curl request. Now I got the readings from the sensors on the itmdump console using a file itm.txt as explained in the discovery book. Now I want to transfer the data from itm.txt to a file so that I can post that data in the string format to the server. Using no_std enviourment. How I can achieve this? can you please suggest me the way? Thanks –  Aug 12 '21 at 11:17

1 Answers1

0

You can't do this. Or at least not as an independent application.

You have a development environment which allows you to transmit sensor data over serial and write it to a file on your computer. (The itmdump you talked about)

However a microcontroller doesn't have a HDD or networking. You need to add the peripherals to communicate to the network and get the network stack to do HTTP. If you have those connected and communicating you can then transmit packets from your board directly to the network server.

itmdump only works because you have a PC with a protocol connected to do the writing to a local file

Tarick Welling
  • 3,119
  • 3
  • 19
  • 44
  • okay, now I understand this..I can use another application and then I can get that data from the itm.txt file and from that another application I can connect o the server and post the data of the sensor. –  Aug 12 '21 at 11:42