Return SP_ERR_SUPP from sp_list_ports() on unsupported platforms.
This commit is contained in:
parent
64690702cb
commit
6b93ede419
4
README
4
README
|
@ -25,8 +25,8 @@ The library should build and work on any Windows or Unix-based system. If it
|
|||
does not, please submit a bug.
|
||||
|
||||
Enumeration is currently only implemented on Windows, Mac OS X and Linux. On
|
||||
other systems enumeration will return no results, but ports can still be opened
|
||||
by name and then used.
|
||||
other systems enumeration is not supported, but ports can still be opened by
|
||||
name and then used.
|
||||
|
||||
If you know how to enumerate available ports on another OS, please submit a bug
|
||||
with this information, or better still a patch implementing it.
|
||||
|
|
15
serialport.c
15
serialport.c
|
@ -246,7 +246,7 @@ fail:
|
|||
enum sp_return sp_list_ports(struct sp_port ***list_ptr)
|
||||
{
|
||||
struct sp_port **list;
|
||||
int ret = SP_OK;
|
||||
int ret = SP_ERR_SUPP;
|
||||
|
||||
TRACE("%p", list_ptr);
|
||||
|
||||
|
@ -269,6 +269,8 @@ enum sp_return sp_list_ports(struct sp_port ***list_ptr)
|
|||
char *name;
|
||||
int name_len;
|
||||
|
||||
ret = SP_OK;
|
||||
|
||||
DEBUG("Opening registry key");
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DEVICEMAP\\SERIALCOMM"),
|
||||
0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS) {
|
||||
|
@ -339,6 +341,8 @@ out_done:
|
|||
CFTypeRef cf_path;
|
||||
Boolean result;
|
||||
|
||||
ret = SP_OK;
|
||||
|
||||
DEBUG("Getting IOKit master port");
|
||||
if (IOMasterPort(MACH_PORT_NULL, &master) != KERN_SUCCESS) {
|
||||
SET_FAIL(ret, "IOMasterPort() failed");
|
||||
|
@ -402,6 +406,8 @@ out_done:
|
|||
int fd, ioctl_result;
|
||||
struct serial_struct serial_info;
|
||||
|
||||
ret = SP_OK;
|
||||
|
||||
DEBUG("Enumerating tty devices");
|
||||
ud = udev_new();
|
||||
ud_enumerate = udev_enumerate_new(ud);
|
||||
|
@ -456,10 +462,13 @@ out:
|
|||
udev_unref(ud);
|
||||
#endif
|
||||
|
||||
if (ret == SP_OK) {
|
||||
switch (ret) {
|
||||
case SP_OK:
|
||||
*list_ptr = list;
|
||||
RETURN_OK();
|
||||
} else {
|
||||
case SP_ERR_SUPP:
|
||||
DEBUG_ERROR(SP_ERR_SUPP, "Enumeration not supported on this platform.");
|
||||
default:
|
||||
if (list)
|
||||
sp_free_port_list(list);
|
||||
*list_ptr = NULL;
|
||||
|
|
Loading…
Reference in New Issue