Device interface library for multiple platforms including Mbed.

Dependents:   DeepCover Embedded Security in IoT MaximInterface MAXREFDES155#

Maxim Interface is a library framework focused on providing flexible and expressive hardware interfaces. Both communication interfaces such as I2C and 1-Wire and device interfaces such as DS18B20 are supported. Modern C++ concepts are used extensively while keeping compatibility with C++98/C++03 and requiring no external dependencies. The embedded-friendly design does not depend on exceptions or RTTI.

The full version of the project is hosted on GitLab: https://gitlab.com/iabenz/MaximInterface

Revision:
10:947d3f44e0a0
Parent:
8:5ea891c7d1a1
--- a/MaximInterfaceCore/HexString.cpp	Fri Sep 27 16:19:38 2019 -0500
+++ b/MaximInterfaceCore/HexString.cpp	Mon Sep 30 09:39:32 2019 -0500
@@ -37,13 +37,10 @@
 
 namespace MaximInterfaceCore {
 
-using std::string;
-using std::vector;
-
 static const int charsPerByte = 2;
 
-string toHexString(span<const uint_least8_t> byteArray) {
-  string hexString;
+std::string toHexString(span<const uint_least8_t> byteArray) {
+  std::string hexString;
   hexString.reserve(byteArray.size() * charsPerByte);
   for (span<const uint_least8_t>::index_type i = 0; i < byteArray.size(); ++i) {
     char hexBuf[charsPerByte + 1];
@@ -53,18 +50,19 @@
   return hexString;
 }
 
-Optional<vector<uint_least8_t> >
-fromHexString(const string & hexString) {
-  Optional<vector<uint_least8_t> > byteArray = vector<uint_least8_t>();
+Optional<std::vector<uint_least8_t> >
+fromHexString(span<const char> hexString) {
+  Optional<std::vector<uint_least8_t> > byteArray =
+      std::vector<uint_least8_t>();
   byteArray->reserve(hexString.size() / charsPerByte);
   char hexBuf[charsPerByte + 1];
   char * const hexBufEnd = hexBuf + charsPerByte;
   *hexBufEnd = '\0';
   char * hexBufIt = hexBuf;
-  for (string::const_iterator hexStringIt = hexString.begin(),
-                              hexStringEnd = hexString.end();
+  for (span<const char>::iterator hexStringIt = hexString.begin(),
+                                  hexStringEnd = hexString.end();
        hexStringIt != hexStringEnd; ++hexStringIt) {
-    if (!std::isspace(*hexStringIt)) {
+    if (!(std::isspace(*hexStringIt) || *hexStringIt == '\0')) {
       *hexBufIt = *hexStringIt;
       if (++hexBufIt == hexBufEnd) {
         char * hexBufParseEnd;