]> sigrok.org Git - libserialport.git/blobdiff - examples/port_info.c
change type of result variables to ssize_t
[libserialport.git] / examples / port_info.c
index 2c3fda64648182268d41a34813ab13b4179a4305..8bf6022046a40c35cd4115ee2074faf2bb22ddcc 100644 (file)
@@ -1,7 +1,9 @@
 #include <libserialport.h>
 #include <stdio.h>
 
-/* Example of how to get information about a serial port. */
+/* 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)
 {
@@ -22,8 +24,7 @@ int main(int argc, char **argv)
         * 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)
-       {
+       if (result != SP_OK) {
                printf("sp_get_port_by_name() failed!\n");
                return -1;
        }
@@ -36,14 +37,11 @@ int main(int argc, char **argv)
         * e.g. native port, USB or Bluetooth. */
        enum sp_transport transport = sp_get_port_transport(port);
 
-       if (transport == SP_TRANSPORT_NATIVE)
-       {
+       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)
-       {
+       } else if (transport == SP_TRANSPORT_USB) {
                /* This is a USB to serial converter of some kind. */
                printf("Type: USB\n");
 
@@ -61,9 +59,7 @@ int main(int argc, char **argv)
                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)
-       {
+       } else if (transport == SP_TRANSPORT_BLUETOOTH) {
                /* This is a Bluetooth serial port. */
                printf("Type: Bluetooth\n");