ccNOos  v0.0.0
Build Portable Microcontroller Applications!
Functions
HMR3300.c File Reference

IMS: ccNOos, Implementation for straight C More...

#include "HMR3300.h"
Include dependency graph for HMR3300.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct eCompDataStruct createEcompDataStruct ()
 
UI_8 ATO_F (const char *str, float *val)
 
UI_8 tryParseEcompData (char *eCompStringin, struct eCompDataStruct *eCompDataPtr)
 

Detailed Description

IMS: ccNOos, Implementation for straight C

Copyright 2021 InMechaSol, Inc

Licensed under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Notes: (.c includes .h) - for straight C or (.cpp includes .c which includes .h) - for C++ wrapped straight C Always compiled to a single compilation unit, either C or CPP, not both

Definition in file HMR3300.c.

Function Documentation

◆ ATO_F()

UI_8 ATO_F ( const char *  str,
float *  val 
)

◆ createEcompDataStruct()

struct eCompDataStruct createEcompDataStruct ( )

Definition at line 1 of file HMR3300.c.

30 {
31  struct eCompDataStruct outStruct;
32  outStruct.pitch = 0;
33  outStruct.roll = 0;
34  outStruct.yaw = 0;
35  return outStruct;
36 }

◆ tryParseEcompData()

UI_8 tryParseEcompData ( char *  eCompStringin,
struct eCompDataStruct eCompDataPtr 
)

Definition at line 43 of file HMR3300.c.

44 {
45  int commaIndex0 = 0;
46  int commaIndex1 = 0;
47 
48  // scan message for valid tokens
49  for (int i = 2; i < charBuffMax; i++)
50  {
51  // find all commas
52  if (eCompStringin[i] == ',')
53  {
54  if(commaIndex0==0)
55  commaIndex0 = i;
56  else if(commaIndex1==0)
57  commaIndex1 = i;
58  else
59  return ui8FALSE;
60  }
61 
62  // find carriage return
63  if (eCompStringin[i] == '\r')
64  {
65  if((commaIndex0>1) && (commaIndex1>(commaIndex0+1)) && (i > (commaIndex1+1)))
66  {
67  // yaw
68  eCompStringin[commaIndex0] = 0x00;
69  if (!ATO_F(&eCompStringin[0], &eCompDataPtr->yaw))
70  {
71  eCompStringin[commaIndex0] = ',';
72  return ui8FALSE;
73  }
74  // pitch
75  eCompStringin[commaIndex1] = 0x00;
76  if (!ATO_F(&eCompStringin[commaIndex0 + 1], &eCompDataPtr->pitch))
77  {
78  eCompStringin[commaIndex1] = ',';
79  return ui8FALSE;
80  }
81  // roll
82  eCompStringin[i] = 0x00;
83  if (!ATO_F(&eCompStringin[commaIndex1 + 1], &eCompDataPtr->roll))
84  {
85  eCompStringin[i] = '\r';
86  return ui8FALSE;
87  }
88  eCompStringin[commaIndex0] = ',';
89  eCompStringin[commaIndex1] = ',';
90  eCompStringin[i] = '\r';
91  return ui8TRUE;
92  }
93  }
94  }
95  return ui8FALSE;
96 
97 
98 }
eCompDataStruct::roll
float roll
Definition: HMR3300.h:35
eCompDataStruct::pitch
float pitch
Definition: HMR3300.h:35
eCompDataStruct
Definition: HMR3300.h:34
ui8FALSE
#define ui8FALSE
Definition: version_config.h:190
eCompDataStruct::yaw
float yaw
Definition: HMR3300.h:35
ATO_F
UI_8 ATO_F(const char *str, float *val)
ui8TRUE
#define ui8TRUE
Definition: version_config.h:191
charBuffMax
#define charBuffMax
Definition: version_config.h:78