Hello, I'm working on a hardware monitor project and I need some help.
I need to extract some data from serial to variables like:
cpuTemperature;
cpuUsage;
gpuTemperature;
gpuUsage;
ramUsage;
ramRemained.
This is an example of what I receive as Serial Data:
C42c 3%|G43c 0%|R8.3GB|RA7.7|RL51|GMT|GMU|GML|GFANL0|GRPM|GPWR|CPU:AMD Ryzen 7 2700XGPU:Radeon RX 570 Series|GCC588|GMC1000|CHC4017|
C(cpuTemperature)c (cpuUsage)%|G(gpuTemperature)c (gpuUsage)%|R(ramUsage)GB|RA(ramRemained)|.... These data are important.
Thank you!
gfvalvo
February 4, 2021, 11:30pm
2
So, where are you stuck? What have you tried so far?
gfvalvo:
So, where are you stuck? What have you tried so far?
I'm a beginner in c++. I tried some codes from youtube but I didn't understand them. I need the whole code to get all data that I mention before.
gfvalvo
February 4, 2021, 11:39pm
4
simion1z1:
I need the whole code to get all data that I mention before.
Sadly, this forum is not a free code writing service. It's purpose is to help people write their own code. You might try posting your question over at Gigs and Collaborations . There you may be able to negotiate a mutually-agreeable price for someone to write the code for you.
Basically 90% of the code for the project I have done it. I need just a method to extract that data in variables.
This is an example of what I receive as Serial Data:
What is the code which reads the serial data?
strtok() will be useful if you have a null terminated character array.
Here is some serial parsing code I use, perhaps it will give a clue or two or not.
void fParseLIDAR_ReceivedSerial ( void * parameters )
{
// distribute received LIDAR info
String sTmp = "";
sTmp.reserve ( 20 );
String sMessage = "";
sMessage.reserve ( StringBufferSize300 );
for ( ;; )
{
EventBits_t xbit = xEventGroupWaitBits (eg, evtParseLIDAR_ReceivedSerial, pdTRUE, pdTRUE, portMAX_DELAY) ;
xQueueReceive ( xQ_LIDAR_Display_INFO, &sMessage, QueueReceiveDelayTime );
int commaIndex = sMessage.indexOf(',');
sTmp.concat ( sMessage.substring(0, commaIndex) );
sMessage.remove( 0, (commaIndex + 1) ); // chop off begining of message
if ( sTmp == "!" )
{
xSemaphoreGive ( sema_LIDAR_OK );
// Display info from LIDAR
sLIDAR_Display_Info = sMessage;
}
if ( sTmp == "$" )
{
xEventGroupSetBits( eg1, evtResetWatchDogVariables );
}
if ( sTmp == "#")
{
xSemaphoreTake( sema_LIDAR_Alarm, xSemaphoreTicksToWait );
sLIDAR_Alarm_info = sMessage;
xSemaphoreGive( sema_LIDAR_Alarm );
xEventGroupSetBits( eg, evtfLIDAR_Alarm );
}
sTmp = "";
sMessage = "";
xSemaphoreGive( sema_ParseLIDAR_ReceivedSerial );
}
vTaskDelete( NULL );
} // void fParseReceivedSerial ( void * parameters )
Robin2
February 5, 2021, 8:27am
8
The parse example in Serial Input Basics may help - it uses strtok()
...R
drmpf
February 6, 2021, 6:29am
9
Check out my GPS parsing example
https://www.forward.com.au/pfod/ArduinoProgramming/Serial_IO/index.html#GPS
How is the input data terminated.
i.e. how do you know when on set of data is finished and another starts?
system
Closed
June 6, 2021, 6:29am
10
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.