D69
-
Content Count
24 -
Joined
-
Last visited
Reputation Activity
-
D69 got a reaction from quochung in [Energia Library] NFC card reading with Energia - MF RC 522
Hi
No, it should be in your libraries folder. Look under the libraries section here
http://energia.nu/Guide_Environment.html
-
D69 got a reaction from quochung in [Energia Library] NFC card reading with Energia - MF RC 522
Looks like you've not installed the library correctly. Double check it's in the right place
-
D69 got a reaction from energia in Odd results coming from a char* array
Hi Graham
After a bit of pondering your code really makes sense, just looking at rewriting mine to incorporate it now, should save a few lines and tidy it all up a bit.
I've not used typedef before but it actually seems quite logical, I'm assuming the order of variables declared should match the order they're listed in the array.
Thanks very much for the assistance, this forum seems to have one of the best user bases I've seen in a while!
-
D69 reacted to roadrunner84 in Odd results coming from a char* array
You're using the wrong design of your data type. You don't have an array of arrays of characters; you have an array of structures where each structure contains a serial number, a name and a sequence id (?).
Try replacing your data type as needed. Whenever you need to cast (force a type onto another type), you need to consider you're using the wrong design of your data.
Usually my answers are more complete, but I'm not capable of that right now.
-
D69 reacted to grahamf72 in Odd results coming from a char* array
@@D69 - the problem you were encountering is fundamental to the way C handles arrays and strings. Firstly, as I'm sure you're aware a string is merely a null-terminated array of characters. So the string "abc" is represented in memory as a group of characters, 'a', 'b', 'c' and '\0'. When you declare your array your array as char * myArray[3][5], you are creating an array of pointers to char arrays, so myArray[2][0] will return the pointer to the string "5", not the actual character 5. To get the character '5' you need to dereference the pointer, ie *(myArray[2][0]).
Personally, for ease of readability, rather than a multi-dimensioned array, I'd probably do something along the lines of:
typedef struct { char CardNo[13]; //1 larger than the maximum size so as to have room for the \0 char Name[5]; char SecurityLevel; } tSecInfo; tSecInfo myArray[5]={{"205928944228","Dad",5},{"1291251914471","Mum",4}, ... }; ... //then access the various parts with things like... Serial.Println(myArray[i].Name); seclevel=myArray[i].SecurityLevel; etc. -
D69 reacted to chicken in Odd results coming from a char* array
Do you try to get the integer values of these strings?
"5","4","3","2","1"
If so, the function you're looking for is atoi (ascii to integer).
secLevel = atoi(myArray[2]);
However, as long as we're talking about a single digit, you can also use
secLevel = myarray[2][i][0]
Note that [0] accesses the first character of the string stored at [2].
Subtract 0x30 (or '0') if you want to have an integer from 0-9, but the switch statement can handle character too ('0' is a character, "0" is a string).
-
D69 reacted to eelcor in [Energia Library] NFC card reading with Energia - MF RC 522
Yup,
That should do the trick. I think I have reproduced your error. The card is detected 2 times in my case, but the data is corrupted, so it gives the wrong output. I applied the usci spi fix from my earlier post et voila, it works like charm! Can you try it as well?
Kind regards, Eelco