mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
code compiles with new structure
This commit is contained in:
42
tests/test_aserial.cpp
Normal file
42
tests/test_aserial.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* test_interface.cpp
|
||||
*
|
||||
* Created on: Dec 25, 2016
|
||||
* Author: rdu
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "wrp_sdk/async_io/async_serial.hpp"
|
||||
|
||||
using namespace wescore;
|
||||
|
||||
void parse_buffer(uint8_t *buf, const size_t bufsize, size_t bytes_received)
|
||||
{
|
||||
std::cout << "parser called" << std::endl;
|
||||
|
||||
for (; bytes_received > 0; bytes_received--)
|
||||
{
|
||||
auto c = *buf++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// ASyncSerial::Ptr serial = ASyncSerial::open_url("/dev/ttyUSB0:115200");
|
||||
std::shared_ptr<ASyncSerial> serial = std::make_shared<ASyncSerial>("/dev/ttyO5", 115200);
|
||||
|
||||
serial->set_receive_callback(parse_buffer);
|
||||
|
||||
if (serial->is_open())
|
||||
std::cout << "serial port opened" << std::endl;
|
||||
|
||||
uint8_t data[8] = {'a','b','c'};
|
||||
|
||||
while (1)
|
||||
{
|
||||
// serial->send_bytes(data, 3);
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user