-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
370c833
commit d428464
Showing
4 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
This directory is intended for the project specific (private) libraries. | ||
PlatformIO will compile them to static libraries and link to executable file. | ||
|
||
The source code of each library should be placed in separate directory, like | ||
"lib/private_lib/[here are source files]". | ||
|
||
For example, see how can be organized `Foo` and `Bar` libraries: | ||
|
||
|--lib | ||
| |--Bar | ||
| | |--docs | ||
| | |--examples | ||
| | |--src | ||
| | |- Bar.c | ||
| | |- Bar.h | ||
| |--Foo | ||
| | |- Foo.c | ||
| | |- Foo.h | ||
| |- readme.txt --> THIS FILE | ||
|- platformio.ini | ||
|--src | ||
|- main.c | ||
|
||
Then in `src/main.c` you should use: | ||
|
||
#include <Foo.h> | ||
#include <Bar.h> | ||
|
||
// rest H/C/CPP code | ||
|
||
PlatformIO will find your libraries automatically, configure preprocessor's | ||
include paths and build them. | ||
|
||
More information about PlatformIO Library Dependency Finder | ||
- http://docs.platformio.org/page/librarymanager/ldf.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; http://docs.platformio.org/page/projectconf.html | ||
|
||
[env:uno] | ||
platform = atmelavr | ||
framework = arduino | ||
board = uno | ||
|
||
[env:due] | ||
platform = atmelsam | ||
framework = arduino | ||
board = due |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <Arduino.h> | ||
#include "SerialTools.h" | ||
|
||
#define m_assert(T,V) if(T != V) { result = (result<<1)|1; } else { result <<= 1; } | ||
#define B115200 115200 | ||
#define GARBAGE 0 | ||
|
||
void setup() { | ||
Serial.begin(B115200); | ||
SerialTools::writeString("Ready!", 6); | ||
while((!Serial.available())||(Serial.read()==GARBAGE)); | ||
|
||
uint16_t result = 0; | ||
int test = 0; | ||
|
||
SerialTools::readData((char*)&test, sizeof(int)); | ||
m_assert(test, 0x0A0B0C0D) | ||
m_assert(SerialTools::readByte(), 0xFF) | ||
m_assert(SerialTools::readFloat(), 0.1F) | ||
m_assert(SerialTools::readDouble(), 0.2) | ||
m_assert(SerialTools::readInt(), -3) | ||
m_assert(SerialTools::readUInt(), 4) | ||
m_assert(SerialTools::readShort(), -5) | ||
m_assert(SerialTools::readUShort(), 6) | ||
|
||
SerialTools::writeInt(result); | ||
} | ||
|
||
void loop() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include "Serial.h" | ||
|
||
#define MSG(x) std::cout << x | ||
#define MSGN(x) std::cout << x << "\n" | ||
#define ERR(x) std::cerr << x << "\n" | ||
#define m_assert(x) (x)&0x01 == 1 ? MSGN("FAIL") : MSGN("PASS") | ||
|
||
int main() { | ||
MSGN("-- BEGIN TEST --"); | ||
|
||
MSG("\nCreating Serial Object... "); | ||
Serial serial("/dev/ttyACM0"); | ||
MSGN("Done!\n"); | ||
|
||
std::string res = serial.readString(); | ||
MSG("Message: "); MSGN(res); | ||
serial.writeByte('R'); | ||
|
||
MSGN("Sending Static Values to Arduino..."); | ||
int bytes = 0x0A0B0C0D; | ||
|
||
serial.writeData((char*)&bytes, 4); | ||
serial.writeByte(0xFF); | ||
serial.writeFloat(0.1F); | ||
serial.writeDouble(0.2); | ||
serial.writeInt(-3); | ||
serial.writeUInt(4); | ||
serial.writeShort(-5); | ||
serial.writeUShort(6); | ||
|
||
MSG("Results: "); | ||
int ires = serial.readInt(); | ||
|
||
MSGN(ires); | ||
MSG("> Sending Bytes\t\t\t"); m_assert(ires>>7); | ||
MSG("> Sending Byte\t\t\t"); m_assert(ires>>6); | ||
MSG("> Sending Float\t\t\t"); m_assert(ires>>5); | ||
MSG("> Sending Double\t\t"); m_assert(ires>>4); | ||
MSG("> Sending Int\t\t\t"); m_assert(ires>>3); | ||
MSG("> Sending Unsigned Int\t\t"); m_assert(ires>>2); | ||
MSG("> Sending Short\t\t\t"); m_assert(ires>>1); | ||
MSG("> Sending Unsigned Short\t"); m_assert(ires>>0); | ||
|
||
MSGN("\n-- END TEST --"); | ||
return 0; | ||
} |