You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "AngusJull (via GitHub)" <gi...@apache.org> on 2025/03/13 20:45:28 UTC

[PR] drivers/sensors/fakesensor: Add baro sensor type to fakesensor [nuttx]

AngusJull opened a new pull request, #15990:
URL: https://github.com/apache/nuttx/pull/15990

   ## Summary
   
   Allow fakesensor to read baro data and publish it in the same way as the other supported fakesensor data types. Adds a single function that reads from a CSV file and publishes new data.
   
   ## Impact
   
   Fakesensor now supports baro data. Slightly more convenient to debug systems that use barometers.
   
   ## Testing
   
   Testing was performed on the NuttX simulator with the sim:nsh configuration (and run on Ubuntu - WSL2). The changes were tested by creating a fakesensor and providing a CSV file with sample barometric data. The data was then collected and printed using the `uorb_listener` application
   
   ```
   nsh> uorb_listener -r 50 -n 10 sensor_baro0
   
   Mointor objects num:1
   object_name:sensor_baro, object_instance:0
   sensor_baro(now:68460409):timestamp:68460374,pressure:976.869995,temperature:24.600000
   sensor_baro(now:68490498):timestamp:68490460,pressure:976.880005,temperature:24.600000
   sensor_baro(now:68530398):timestamp:68530364,pressure:976.669983,temperature:24.600000
   sensor_baro(now:68560472):timestamp:68560437,pressure:976.830017,temperature:24.600000
   sensor_baro(now:68590508):timestamp:68590473,pressure:976.809998,temperature:24.600000
   sensor_baro(now:68630274):timestamp:68630246,pressure:976.440002,temperature:24.600000
   sensor_baro(now:68660253):timestamp:68660234,pressure:975.960022,temperature:24.600000
   sensor_baro(now:68690264):timestamp:68690245,pressure:975.880005,temperature:24.600000
   sensor_baro(now:68720338):timestamp:68720314,pressure:976.340027,temperature:24.600000
   sensor_baro(now:68750468):timestamp:68750426,pressure:975.659973,temperature:24.600000
   Object name:sensor_baro0, recieved:10
   Total number of received Message:10/10
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors/fakesensor: Add baro sensor type to fakesensor [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #15990:
URL: https://github.com/apache/nuttx/pull/15990#discussion_r1996152509


##########
drivers/sensors/fakesensor_uorb.c:
##########
@@ -197,6 +197,20 @@ static inline void fakesensor_read_gyro(FAR struct fakesensor_s *sensor,
                     sizeof(struct sensor_gyro));
 }
 
+static inline void fakesensor_read_baro(FAR struct fakesensor_s *sensor,
+                                        uint64_t event_timestamp)
+{
+  struct sensor_baro baro;
+  char raw[50];

Review Comment:
   Suggestion, replace hard-coded 50 with some #define BARO_SAMPLES_NUM 50, this way people could find and modify it easily.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors/fakesensor: Add baro sensor type to fakesensor [nuttx]

Posted by "AngusJull (via GitHub)" <gi...@apache.org>.
AngusJull commented on code in PR #15990:
URL: https://github.com/apache/nuttx/pull/15990#discussion_r1996039868


##########
drivers/sensors/fakesensor_uorb.c:
##########
@@ -197,6 +197,19 @@ static inline void fakesensor_read_gyro(FAR struct fakesensor_s *sensor,
                     sizeof(struct sensor_gyro));
 }
 
+static inline void fakesensor_read_baro(FAR struct fakesensor_s *sensor,
+                                        uint64_t event_timestamp)
+{
+  struct sensor_baro baro;
+  char raw[50];
+  fakesensor_read_csv_line(
+          &sensor->data, raw, sizeof(raw), sensor->raw_start);
+  sscanf(raw, "%f,%f\n", &baro.pressure, &baro.temperature);
+  baro.timestamp = event_timestamp;
+  sensor->lower.push_event(sensor->lower.priv, &baro,
+                           sizeof(struct sensor_baro));
+}

Review Comment:
   Updated the formatting to exactly as you've requested. Thanks for the feedback!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors/fakesensor: Add baro sensor type to fakesensor [nuttx]

Posted by "AngusJull (via GitHub)" <gi...@apache.org>.
AngusJull commented on code in PR #15990:
URL: https://github.com/apache/nuttx/pull/15990#discussion_r1999893516


##########
drivers/sensors/fakesensor_uorb.c:
##########
@@ -197,6 +197,20 @@ static inline void fakesensor_read_gyro(FAR struct fakesensor_s *sensor,
                     sizeof(struct sensor_gyro));
 }
 
+static inline void fakesensor_read_baro(FAR struct fakesensor_s *sensor,
+                                        uint64_t event_timestamp)
+{
+  struct sensor_baro baro;
+  char raw[50];

Review Comment:
   I could add this, but it might be worth adding such configuration options to the rest of the fakesensors as well for consistency at that point (which all use this 50 character hardcoded length). I think it's probably fine to just leave for now since it would be hard to get past 50 chars using two floats.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors/fakesensor: Add baro sensor type to fakesensor [nuttx]

Posted by "lupyuen (via GitHub)" <gi...@apache.org>.
lupyuen commented on code in PR #15990:
URL: https://github.com/apache/nuttx/pull/15990#discussion_r1994654504


##########
drivers/sensors/fakesensor_uorb.c:
##########
@@ -197,6 +197,19 @@ static inline void fakesensor_read_gyro(FAR struct fakesensor_s *sensor,
                     sizeof(struct sensor_gyro));
 }
 
+static inline void fakesensor_read_baro(FAR struct fakesensor_s *sensor,
+                                        uint64_t event_timestamp)
+{
+  struct sensor_baro baro;
+  char raw[50];
+  fakesensor_read_csv_line(
+          &sensor->data, raw, sizeof(raw), sensor->raw_start);
+  sscanf(raw, "%f,%f\n", &baro.pressure, &baro.temperature);
+  baro.timestamp = event_timestamp;
+  sensor->lower.push_event(sensor->lower.priv, &baro,
+                           sizeof(struct sensor_baro));
+}

Review Comment:
   Sorry the indentation is a bit odd, could we change to this? Thanks :-)
   ```c
     struct sensor_baro baro;
     char raw[50];
   
     fakesensor_read_csv_line(&sensor->data, raw, sizeof(raw),
                              sensor->raw_start);
     sscanf(raw, "%f,%f\n", &baro.pressure, &baro.temperature);
     baro.timestamp = event_timestamp;
     sensor->lower.push_event(sensor->lower.priv, &baro,
                              sizeof(struct sensor_baro));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors/fakesensor: Add baro sensor type to fakesensor [nuttx]

Posted by "nuttxpr (via GitHub)" <gi...@apache.org>.
nuttxpr commented on PR #15990:
URL: https://github.com/apache/nuttx/pull/15990#issuecomment-2722661898

   [**\[Experimental Bot, please feedback here\]**](https://github.com/search?q=repo%3Aapache%2Fnuttx+13552&type=issues)
   
   
   
   Yes, this PR appears to meet the NuttX requirements, although some clarifications and additions would make it even stronger.
   
   **Strengths:**
   
   * **Clear Summary:** The summary provides a concise explanation of the change, its purpose, and how it works.
   * **Impact Description:**  The impact section addresses the user impact and mentions increased convenience for debugging.
   * **Testing Evidence:** The testing section includes the host and target environment details and provides logs demonstrating the functionality before and after the change (although "before" logs are missing, see below).
   
   **Areas for Improvement:**
   
   * **Missing Information in Impact:**  While user impact is addressed, other impact areas are left blank.  Even if there's no impact, explicitly stating "NO" for each is important for reviewers.  For example:
       * *Impact on build (will build process change)? NO*
       * *Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO*
       * *Impact on documentation (is update required / provided)? YES (Added documentation for the new fakesensor baro functionality).* (Assuming you've documented the feature).
       * *Impact on security (any sort of implications)? NO*
       * *Impact on compatibility (backward/forward/interoperability)? NO*
   * **Missing "Before" Logs:**  The testing section mentions "Testing logs before change," but doesn't actually include them.  Show the output of `uorb_listener sensor_baro0` *before* the change to demonstrate that baro data wasn't previously available.
   * **Consider Edge Cases in Testing:**  While the provided test case demonstrates basic functionality, consider adding tests for edge cases or error handling. For example:
       * What happens if the CSV file is malformed?
       * What happens if the CSV file doesn't exist?
       * What are the limits on the data rates/sizes that can be handled?
   * **Related Issues:** If this addresses a specific issue in NuttX or NuttX Apps, be sure to link it in the Summary.
   
   
   **Example of Improved Impact Section:**
   
   ```
   ## Impact
   
   * Is new feature added? YES (Fakesensor now supports baro data.)
   * Is existing feature changed? NO
   * Impact on user (will user need to adapt to change)? YES (Users can now use fakesensor to simulate baro data.)
   * Impact on build (will build process change)? NO
   * Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO
   * Impact on documentation (is update required / provided)? YES (Added documentation for the new fakesensor baro functionality in the fakesensor README.)
   * Impact on security (any sort of implications)? NO
   * Impact on compatibility (backward/forward/interoperability)? NO
   * Anything else to consider? NO
   ```
   
   
   By addressing these points, you'll make your PR easier to review and increase the likelihood of it being merged quickly.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors/fakesensor: Add baro sensor type to fakesensor [nuttx]

Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl merged PR #15990:
URL: https://github.com/apache/nuttx/pull/15990


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors/fakesensor: Add baro sensor type to fakesensor [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #15990:
URL: https://github.com/apache/nuttx/pull/15990#issuecomment-2724741498

   Nice contribution @AngusJull !!!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org