Getting information on a particular serial port.
Getting information on a particular serial port.
#include <stdio.h>
int main(int argc, char **argv)
{
if (argc != 2) {
printf("Usage: %s <port name>\n", argv[0]);
return -1;
}
char *port_name = argv[1];
printf("Looking for port %s.\n", port_name);
printf("sp_get_port_by_name() failed!\n");
return -1;
}
printf("Type: Native\n");
printf("Type: USB\n");
int usb_vid, usb_pid;
printf("VID: %04X PID: %04X\n", usb_vid, usb_pid);
int usb_bus, usb_address;
printf("Bus: %d Address: %d\n", usb_bus, usb_address);
printf("Type: Bluetooth\n");
}
printf("Freeing port.\n");
return 0;
}
sp_transport
Transport types.
@ SP_TRANSPORT_USB
USB serial port adapter.
@ SP_TRANSPORT_NATIVE
Native platform serial port.
@ SP_TRANSPORT_BLUETOOTH
Bluetooth serial port adapter.
@ SP_OK
Operation completed successfully.
void sp_free_port(struct sp_port *port)
Free a port structure obtained from sp_get_port_by_name() or sp_copy_port().
enum sp_return sp_get_port_by_name(const char *portname, struct sp_port **port_ptr)
Obtain a pointer to a new sp_port structure representing the named port.
char * sp_get_port_usb_serial(const struct sp_port *port)
Get the USB serial number string of a USB serial adapter port.
enum sp_transport sp_get_port_transport(const struct sp_port *port)
Get the transport type used by a port.
char * sp_get_port_usb_manufacturer(const struct sp_port *port)
Get the USB manufacturer string of a USB serial adapter port.
char * sp_get_port_usb_product(const struct sp_port *port)
Get the USB product string of a USB serial adapter port.
enum sp_return sp_get_port_usb_vid_pid(const struct sp_port *port, int *usb_vid, int *usb_pid)
Get the USB Vendor ID and Product ID of a USB serial adapter port.
char * sp_get_port_description(const struct sp_port *port)
Get a description for a port, to present to end user.
enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port, int *usb_bus, int *usb_address)
Get the USB bus number and address on bus of a USB serial adapter port.
char * sp_get_port_bluetooth_address(const struct sp_port *port)
Get the MAC address of a Bluetooth serial adapter port.
char * sp_get_port_name(const struct sp_port *port)
Get the name of a port.
An opaque structure representing a serial port.