Loïc G. Geschrieben August 12, 2022 at 14:47 Geschrieben August 12, 2022 at 14:47 Hello ! I'm trying to get the data from a Outdoor Weather bricklet using the C/C++ bindings from uC. I want to use `tf_outdoor_weather_get_station_data` instead of the callback methods. For this I first need to get the station identifier using `tf_outdoor_weather_get_station_identifiers` but I'm unable to get it to work. uint8_t * stations_id; uint16_t * station_nb; tf_outdoor_weather_get_station_identifiers(&ow, stations_id, station_nb); tf_hal_printf("nb: %I16u - station 1: %I16u\n", station_nb, stations_id); Returns 0 for both the values. I get correct values when using the callback methods so the communication is working. Any clue on what I'm doing wrong ? Zitieren
Loïc G. Geschrieben August 13, 2022 at 18:18 Autor Geschrieben August 13, 2022 at 18:18 I finally got it working : uint8_t stations_id[255]; uint16_t station_nb; tf_outdoor_weather_get_station_identifiers(&this->ow, stations_id, &station_nb); I think it can be done in a better way using a pointer instead of a array of 255 uint8_t elements but my C++ skills are still limited. Zitieren
rtrbt Geschrieben August 16, 2022 at 13:30 Geschrieben August 16, 2022 at 13:30 On 8/13/2022 at 8:18 PM, Loïc G. said: I think it can be done in a better way using a pointer instead of a array of 255 uint8_t elements Nope, you have to pass a buffer with enough space for 256(!) entries. The station IDs are collected in this buffer and the Bricklet can detect up to 256 stations. Theoretically you cound call tf_outdoor_weather_get_station_identifiers(&this->ow, nullptr, &station_nb); first to get the number of stations and then creating a buffer that is large enough, for example with uint8_t *stations_id = (uint8_t*) malloc(stations_nb * sizeof(uint8_t)); However this is dangerous, as the Bricklet could receive another new station after the call to get the number of stations, but before the second call to get the station IDs. So don't do this! Zitieren
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.