Skip to content

Added support for physical Ticket Dispenser / Coin Hopper #13512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions 3rdparty/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.15)

project(serial CXX)

# Platform-specific source files
set(SERIAL_PLATFORM_SRCS)
if(WINDOWS)
list(APPEND SERIAL_PLATFORM_SRCS
src/impl/win.cc
src/impl/list_ports/list_ports_win.cc
)
elseif(UNIX)
list(APPEND SERIAL_PLATFORM_SRCS
src/impl/unix.cc
src/impl/list_ports/list_ports_linux.cc
)
if(APPLE)
list(APPEND SERIAL_PLATFORM_SRCS src/impl/list_ports/list_ports_osx.cc)
endif()
endif()

# Core serial library sources
set(SERIAL_SRCS
src/serial.cc
${SERIAL_PLATFORM_SRCS}
)

# Create static library
add_library(serial STATIC ${SERIAL_SRCS})

# Include directories
target_include_directories(serial PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)

# Set C++ standard
set_target_properties(serial PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)

# Platform-specific libraries
if(WINDOWS)
target_link_libraries(serial PRIVATE setupapi)
elseif(UNIX)
if(APPLE)
find_library(IOKIT_LIBRARY IOKit)
find_library(FOUNDATION_LIBRARY Foundation)
target_link_libraries(serial PRIVATE ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
else()
target_link_libraries(serial PRIVATE rt pthread)
endif()
endif()
7 changes: 7 additions & 0 deletions 3rdparty/serial/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2012 William Woodall, John Harrison

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63 changes: 63 additions & 0 deletions 3rdparty/serial/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Serial Communication Library

[![Build Status](https://travis-ci.org/wjwwood/serial.svg?branch=master)](https://travis-ci.org/wjwwood/serial)*(Linux and OS X)* [![Build Status](https://ci.appveyor.com/api/projects/status/github/wjwwood/serial)](https://ci.appveyor.com/project/wjwwood/serial)*(Windows)*

This is a cross-platform library for interfacing with rs-232 serial like ports written in C++. It provides a modern C++ interface with a workflow designed to look and feel like PySerial, but with the speed and control provided by C++.

This library is in use in several robotics related projects and can be built and installed to the OS like most unix libraries with make and then sudo make install, but because it is a catkin project it can also be built along side other catkin projects in a catkin workspace.

Serial is a class that provides the basic interface common to serial libraries (open, close, read, write, etc..) and requires no extra dependencies. It also provides tight control over timeouts and control over handshaking lines.

### Documentation

Website: http://wjwwood.github.io/serial/

API Documentation: http://wjwwood.github.io/serial/doc/1.1.0/index.html

### Dependencies

Required:
* [catkin](http://www.ros.org/wiki/catkin) - cmake and Python based buildsystem
* [cmake](http://www.cmake.org) - buildsystem
* [Python](http://www.python.org) - scripting language
* [empy](http://www.alcyone.com/pyos/empy/) - Python templating library
* [catkin_pkg](http://pypi.python.org/pypi/catkin_pkg/) - Runtime Python library for catkin

Optional (for documentation):
* [Doxygen](http://www.doxygen.org/) - Documentation generation tool
* [graphviz](http://www.graphviz.org/) - Graph visualization software

### Install

Get the code:

git clone https://github.com/wjwwood/serial.git

Build:

make

Build and run the tests:

make test

Build the documentation:

make doc

Install:

make install

### License

[The MIT License](LICENSE)

### Authors

William Woodall <[email protected]>
John Harrison <[email protected]>

### Contact

William Woodall <[email protected]>
221 changes: 221 additions & 0 deletions 3rdparty/serial/include/serial/impl/unix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
/*!
* \file serial/impl/unix.h
* \author William Woodall <[email protected]>
* \author John Harrison <[email protected]>
* \version 0.1
*
* \section LICENSE
*
* The MIT License
*
* Copyright (c) 2012 William Woodall, John Harrison
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* \section DESCRIPTION
*
* This provides a unix based pimpl for the Serial class. This implementation is
* based off termios.h and uses select for multiplexing the IO ports.
*
*/

#if !defined(_WIN32)

#ifndef SERIAL_IMPL_UNIX_H
#define SERIAL_IMPL_UNIX_H

#include "serial/serial.h"

#include <pthread.h>

namespace serial {

using std::size_t;
using std::string;
using std::invalid_argument;

using serial::SerialException;
using serial::IOException;

class MillisecondTimer {
public:
MillisecondTimer(const uint32_t millis);
int64_t remaining();

private:
static timespec timespec_now();
timespec expiry;
};

class serial::Serial::SerialImpl {
public:
SerialImpl (const string &port,
unsigned long baudrate,
bytesize_t bytesize,
parity_t parity,
stopbits_t stopbits,
flowcontrol_t flowcontrol);

virtual ~SerialImpl ();

void
open ();

void
close ();

bool
isOpen () const;

size_t
available ();

bool
waitReadable (uint32_t timeout);

void
waitByteTimes (size_t count);

size_t
read (uint8_t *buf, size_t size = 1);

size_t
write (const uint8_t *data, size_t length);

void
flush ();

void
flushInput ();

void
flushOutput ();

void
sendBreak (int duration);

void
setBreak (bool level);

void
setRTS (bool level);

void
setDTR (bool level);

bool
waitForChange ();

bool
getCTS ();

bool
getDSR ();

bool
getRI ();

bool
getCD ();

void
setPort (const string &port);

string
getPort () const;

void
setTimeout (Timeout &timeout);

Timeout
getTimeout () const;

void
setBaudrate (unsigned long baudrate);

unsigned long
getBaudrate () const;

void
setBytesize (bytesize_t bytesize);

bytesize_t
getBytesize () const;

void
setParity (parity_t parity);

parity_t
getParity () const;

void
setStopbits (stopbits_t stopbits);

stopbits_t
getStopbits () const;

void
setFlowcontrol (flowcontrol_t flowcontrol);

flowcontrol_t
getFlowcontrol () const;

void
readLock ();

void
readUnlock ();

void
writeLock ();

void
writeUnlock ();

protected:
void reconfigurePort ();

private:
string port_; // Path to the file descriptor
int fd_; // The current file descriptor

bool is_open_;
bool xonxoff_;
bool rtscts_;

Timeout timeout_; // Timeout for read operations
unsigned long baudrate_; // Baudrate
uint32_t byte_time_ns_; // Nanoseconds to transmit/receive a single byte

parity_t parity_; // Parity
bytesize_t bytesize_; // Size of the bytes
stopbits_t stopbits_; // Stop Bits
flowcontrol_t flowcontrol_; // Flow Control

// Mutex used to lock the read functions
pthread_mutex_t read_mutex;
// Mutex used to lock the write functions
pthread_mutex_t write_mutex;
};

}

#endif // SERIAL_IMPL_UNIX_H

#endif // !defined(_WIN32)
Loading