MCPcopy Create free account
hub / github.com/SmingHub/Sming / testPSTR

Function testPSTR

samples/Basic_ProgMem/app/TestProgmem.cpp:42–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42void 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
85void testFSTR(Print& out)
86{

Callers 1

testProgmemFunction · 0.85

Calls 5

m_printHexFunction · 0.85
printlnMethod · 0.80
FFunction · 0.50
printMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected