Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 5:e8936f38a338, committed 2015-10-14
- Comitter:
- Overdrivr
- Date:
- Wed Oct 14 09:42:32 2015 +0000
- Parent:
- 4:d675ad9c57ff
- Child:
- 6:72d46dbdbe7a
- Commit message:
- Added emergency send
Changed in this revision
| distantio.cpp | Show annotated file Show diff for this revision Revisions of this file |
| distantio.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/distantio.cpp Tue Oct 13 12:20:44 2015 +0000
+++ b/distantio.cpp Wed Oct 14 09:42:32 2015 +0000
@@ -178,6 +178,65 @@
encode(buffer,FRAMESIZE);
}
+ void dIO_emergency_send(void* ptr, uint16_t size, dio_type type, char* name, float recordingtime, uint16_t index)
+ {
+
+ static uint8_t buffer[FRAMESIZE];
+
+ // Response code 0x09
+ buffer[0] = 0x09;
+
+ // Write variable ID
+ uint8_t * temp_ptr = (uint8_t*)(name);
+ buffer[1] = *(temp_ptr + 1);
+ buffer[2] = *(temp_ptr);
+
+ // Write variable type
+ buffer[3] = type;
+
+ // Extra identifier 1
+ temp_ptr = (uint8_t*)(&recordingtime);
+ buffer[4] = *(temp_ptr + 3);
+ buffer[5] = *(temp_ptr + 2);
+ buffer[6] = *(temp_ptr + 1);
+ buffer[7] = *(temp_ptr );
+
+ // Extra identifier 2
+ temp_ptr = (uint8_t*)(&index);
+ buffer[8] = *(temp_ptr + 1);
+ buffer[9] = *(temp_ptr );
+
+ uint16_t i = 10;
+
+ // Write data
+ for(uint16_t k = 0 ; k < DATASIZE ; k++)
+ {
+ uint16_t off = DATASIZE - 1 - k;
+
+ // Fill buffer with data
+ if(off < size)
+ {
+ temp_ptr = (uint8_t*)(ptr) + off ;
+ buffer[i++] = *temp_ptr;
+ }
+ // Fill remaining bits with 0
+ else
+ {
+ buffer[i++] = 0;
+ }
+ }
+
+ // Compute crc
+ uint16_t crc_value = crc16(buffer,i);
+
+ // Write crc into buffer's last byte
+ buffer[i++] = (crc_value >> 8) & 0xFF;
+ buffer[i++] = crc_value & 0xFF;
+
+ // Encode frame
+ encode(buffer,i);
+ }
+
/* ------------------- PRIVATE FUNCTIONS ------------------ */
void _dIO_send_descriptor(uint16_t index)
--- a/distantio.h Tue Oct 13 12:20:44 2015 +0000 +++ b/distantio.h Wed Oct 14 09:42:32 2015 +0000 @@ -87,7 +87,7 @@ /** Starts a new group. Any subsequent call to @dio_var will register the variable under this new group. * Groups also have descriptors that can be queried from master-side. - * @param groupname name of the variable group. + * @param groupname name of the variable group. Limited to 14 characters. * */ void dIO_group(char* groupname); @@ -112,4 +112,17 @@ */ void dIO_send_alive(); +/** Manual mode for sending special data in case of particular events. + * This is useful to debug issues happening much faster than human perception, because this data will be exported master-side to an excel file. + * This mode can also support arrays by calling it for each array index and specifying that index as last parameter. + * Master-side, data is sorted in a hierchical manner, first by name, then by recording time, then by index (see parameters). + * @param ptr Pointer to the data start adress + * @param size Size in bytes of the data. Use sizeof(..) to avoid mistakes. + * @param type Type of the variable. For a list of possible types @see dio_type + * @param name Quick custom name for the variable. Limited to 2 characters for now. + * @param recordingtime User-specified field intented for associating a specific time with the data + * @param index User-specified field for associating a specific index to the data. + */ + void dIO_emergency_send(void* ptr, uint16_t size, dio_type type, char* name, float recordingtime, uint16_t index = 0); + #endif /* DISTANTIO_H_ */