| 40 | } |
| 41 | |
| 42 | void testPSTR(Print& out) |
| 43 | { |
| 44 | // |
| 45 | out.println(_F("Simple PSTR example using stack\n")); |
| 46 | |
| 47 | // |
| 48 | out.println(F("Simple PSTR example using heap (String object)\n")); |
| 49 | |
| 50 | // Note that characters after first nul won't be shown ... |
| 51 | out.print("> demoPSTR1 (print char*): "); |
| 52 | { |
| 53 | LOAD_PSTR(s, demoPSTR1) |
| 54 | out << '"' << s << '"' << endl; |
| 55 | } |
| 56 | |
| 57 | // ... now they will: note buf will be aligned up to next dword boundary though |
| 58 | out.print("> demoPSTR1 (write): "); |
| 59 | LOAD_PSTR(buf, demoPSTR1); |
| 60 | out.print('"'); |
| 61 | out.write(buf, sizeof(buf) - 1); |
| 62 | out.println('"'); |
| 63 | m_printHex("hex", buf, sizeof(buf)); // show the actual data |
| 64 | |
| 65 | // PSR defined in another module - we don't know its size! so have to guess, |
| 66 | // and of course nuls don't get included |
| 67 | out.print("> externalPSTR1 (print char*): "); |
| 68 | char buf2[100]; |
| 69 | strncpy_P(buf2, externalPSTR1, sizeof(buf2)); |
| 70 | buf2[sizeof(buf2) - 1] = '\0'; |
| 71 | out << '"' << buf2 << '"' << endl; |
| 72 | |
| 73 | // |
| 74 | out.print("> PSTR_ARRAY: "); |
| 75 | PSTR_ARRAY(psarr, DEMO_TEST_TEXT); |
| 76 | out.print('"'); |
| 77 | out.write(psarr, sizeof(__pstr__psarr) - 1); |
| 78 | out.println('"'); |
| 79 | m_printHex("hex", psarr, sizeof(__pstr__psarr)); |
| 80 | |
| 81 | // |
| 82 | out.println("< testPSTR() end\n"); |
| 83 | } |
| 84 | |
| 85 | void testFSTR(Print& out) |
| 86 | { |
no test coverage detected