Commit e23c2f50 authored by phil's avatar phil
Browse files

initial commit

parents
cmake_minimum_required(VERSION 3.19)
project(mobspkr_vehicle_ctrl)
#set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(SERIALPORT_INCLUDE_DIRS "/usr/local/Cellar/libserialport/0.1.1/include")
set(CMAKE_CXX_STANDARD 14)
include_directories(${SERIALPORT_INCLUDE_DIRS})
link_directories("/usr/local/lib/")
link_libraries(serialport)
add_executable(list-ports src/utils/list_ports.c)
add_executable(port-info src/utils/port_info.c)
Mobile Speaker: Vehicle Controller
MIT License
Copyright (c) 2021 ICST / ZHdK
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.
\ No newline at end of file
# Mobile Speaker: Vehicle Controller
An OSC based proxy controller for a vehicle driven by two Trinamic PD60-3-1160 stepper motors.
# Building
## macOS
```bash
brew install libserialport
```
## Linux
```bash
sudo apt install libserialport0 libserialport-dev
```
# License
MIT License
Copyright 2021 ICST / ZHdK
#include <libserialport.h>
#include <stdio.h>
/* Example of how to get a list of serial ports on the system.
*
* This example file is released to the public domain. */
int main(int argc, char **argv)
{
/* A pointer to a null-terminated array of pointers to
* struct sp_port, which will contain the ports found.*/
struct sp_port **port_list;
printf("Getting port list.\n");
/* Call sp_list_ports() to get the ports. The port_list
* pointer will be updated to refer to the array created. */
enum sp_return result = sp_list_ports(&port_list);
if (result != SP_OK) {
printf("sp_list_ports() failed!\n");
return -1;
}
/* Iterate through the ports. When port_list[i] is NULL
* this indicates the end of the list. */
int i;
for (i = 0; port_list[i] != NULL; i++) {
struct sp_port *port = port_list[i];
/* Get the name of the port. */
char *port_name = sp_get_port_name(port);
printf("Found port: %s\n", port_name);
}
printf("Found %d ports.\n", i);
printf("Freeing port list.\n");
/* Free the array created by sp_list_ports(). */
sp_free_port_list(port_list);
/* Note that this will also free all the sp_port structures
* it points to. If you want to keep one of them (e.g. to
* use that port in the rest of your program), take a copy
* of it first using sp_copy_port(). */
return 0;
}
#include <libserialport.h>
#include <stdio.h>
/* Example of how to get information about a serial port.
*
* This example file is released to the public domain. */
int main(int argc, char **argv)
{
/* Get the port name from the command line. */
if (argc != 2) {
printf("Usage: %s <port name>\n", argv[0]);
return -1;
}
char *port_name = argv[1];
/* A pointer to a struct sp_port, which will refer to
* the port found. */
struct sp_port *port;
printf("Looking for port %s.\n", port_name);
/* Call sp_get_port_by_name() to find the port. The port
* pointer will be updated to refer to the port found. */
enum sp_return result = sp_get_port_by_name(port_name, &port);
if (result != SP_OK) {
printf("sp_get_port_by_name() failed!\n");
return -1;
}
/* Display some basic information about the port. */
printf("Port name: %s\n", sp_get_port_name(port));
printf("Description: %s\n", sp_get_port_description(port));
/* Identify the transport which this port is connected through,
* e.g. native port, USB or Bluetooth. */
enum sp_transport transport = sp_get_port_transport(port);
if (transport == SP_TRANSPORT_NATIVE) {
/* This is a "native" port, usually directly connected
* to the system rather than some external interface. */
printf("Type: Native\n");
} else if (transport == SP_TRANSPORT_USB) {
/* This is a USB to serial converter of some kind. */
printf("Type: USB\n");
/* Display string information from the USB descriptors. */
printf("Manufacturer: %s\n", sp_get_port_usb_manufacturer(port));
printf("Product: %s\n", sp_get_port_usb_product(port));
printf("Serial: %s\n", sp_get_port_usb_serial(port));
/* Display USB vendor and product IDs. */
int usb_vid, usb_pid;
sp_get_port_usb_vid_pid(port, &usb_vid, &usb_pid);
printf("VID: %04X PID: %04X\n", usb_vid, usb_pid);
/* Display bus and address. */
int usb_bus, usb_address;
sp_get_port_usb_bus_address(port, &usb_bus, &usb_address);
printf("Bus: %d Address: %d\n", usb_bus, usb_address);
} else if (transport == SP_TRANSPORT_BLUETOOTH) {
/* This is a Bluetooth serial port. */
printf("Type: Bluetooth\n");
/* Display Bluetooth MAC address. */
printf("MAC: %s\n", sp_get_port_bluetooth_address(port));
}
printf("Freeing port.\n");
/* Free the port structure created by sp_get_port_by_name(). */
sp_free_port(port);
/* Note that this will also free the port name and other
* strings retrieved from the port structure. If you want
* to keep these, copy them before freeing the port. */
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment