HashMap.h Library problem

Hi, I’m new to arduino, I need some help.

I have downloaded arduino and the HashMap.h zip file, uncompressed it, and put it inside Documents/Arduino/libraries.

I tried running the example HelloHashMap and it keeps giving me

In file included from HelloHashMap.pde:1:
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:65: error: 'byte' has not been declared
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:78: error: 'byte' does not name a type
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:103: error: 'byte' does not name a type
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h: In constructor 'HashMap<hash, map>::HashMap(HashType<hash, map>*, int)':
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:67: error: 'size' was not declared in this scope
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:68: error: 'byte' was not declared in this scope
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:68: error: expected `;' before 'i'
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:68: error: 'i' was not declared in this scope
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h: In member function 'map HashMap<hash, map>::getValueOf(hash)':
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:86: error: 'byte' was not declared in this scope
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:86: error: expected `;' before 'i'
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:86: error: 'i' was not declared in this scope
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:86: error: 'size' was not declared in this scope
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h: In member function 'void HashMap<hash, map>::debug()':
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:94: error: 'byte' was not declared in this scope
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:94: error: expected `;' before 'i'
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:94: error: 'i' was not declared in this scope
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:94: error: 'size' was not declared in this scope
/Users/#/Documents/Arduino/libraries/HashMap/HashMap.h:95: error: 'Serial' was not declared in this scope
HelloHashMap.pde: In function 'void setup()':
HelloHashMap:19: error: 'class HashMap<char*, int>' has no member named 'getIndexOf'

I have no clue why. All the other built in libraries work fine. Can someone help me?

Hi, the version I found in the playground looks a bit old (2009?) and includes obsolete files. Unless you have a more recent version I would advise not to use it. A more interesting alternative is the port of the STL The Standard Template Library (STL) for AVR with C++ streams | Andys Workshop, which include hashmaps. Beware of memory limitations, however.

Hi,

Thanks for the reply.

I have downloaded STL from the website. Being new to Arduino (and C/C++), I have no idea how to use the library.

How can I make a hash map?

There is a simple example of hashmap on the website. But I wonder why, being new to C and C++, you may want to start from there. I would start by getting acquainted with the basic structure of an Arduino sketch – the setup() and loop() functions, other predefined functions such as pinMode(), delay(), digitalWrite(). I would try the example sketches and make changes to them. The Arduino is not the best platform to learn C or C++ as programming languages, but it’s much more fun if you start throwing some interactivity into your programs.

I'm actually working on a project that requires me to obtain data from a treadmill. Many fitness equipment utilizes CSAFE Protocol for data transfer. I found a similar project that uses python to get data from a rower through CSAFE. http://www.newhavenrowingclub.org/pyrow/
It uses a python dictionary to map the commands to its hex codes, after which I learned that dictionaries in python are similar to associative arrays/hash maps, which is why I'm interested in them. I guess this stuff is better for project guidance, but do you have any suggestions?

http://www.fitlinxx.com/csafe/Commands.htm

A good post on hashmaps: http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_hashtable.aspx. I also want to thank you for the info on the Csafe protocol -- something new to me.

As for the Arduino, you probably know already that the Arduino has a very limited memory, while hashmaps are usually built for efficiency (in insertion and lookup) at the expense of memory. Which means that if I had to choose, I would try not to use them on Arduino, I would just use the hex codes.

Also consider that the maps you need are defined by the protocol, and not going to change during the execution of the program. In C/C++ you may use the keyword #define to create a sort of mapping between two strings, so for example, if you put in your source code:

#define CMD_GETSTATUS 0x80

then you can use CMD_GETSTATUS in the rest of your code wherever you want to write 80Hex. So you can have code which is readable and understandable without using hashmaps. In addition to the #define directive you should also learn about bitwise operations (also required for using the protocol). There are lots of examples around, but just to get you started you may look at the Arduino reference:
Arduino - Home.

Hi please help me how we can use Arduino library in espidf because i am using hasmap library it is fine working in Arduino but not working in espidf. Please if you have any idea please help me.