And so it begins again; bump version number to 6.5_pre

Move some serial port code directly into portNames(); meant to do this for 6.4, oh well.
This commit is contained in:
Stephen Anthony 2020-11-02 14:20:42 -03:30
parent bc4e4586f7
commit 270d29000e
5 changed files with 21 additions and 47 deletions

View File

@ -18,7 +18,7 @@
#ifndef VERSION_HXX
#define VERSION_HXX
#define STELLA_VERSION "6.4"
#define STELLA_VERSION "6.5_pre"
#define STELLA_BUILD "6238"
#endif

View File

@ -99,32 +99,28 @@ StringList SerialPortMACOS::portNames()
{
StringList ports;
// Check if port is valid; for now that means if it can be opened
// Eventually we may extend this to do more intensive checks
auto isPortValid = [](const string& port) {
int handle = open(port.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
if(handle > 0) close(handle);
return handle > 0;
};
// Get all possible devices in the '/dev' directory
FilesystemNode::NameFilter filter = [](const FilesystemNode& node) {
return BSPF::startsWithIgnoreCase(node.getPath(), "/dev/cu.usb");
};
FSList portList;
portList.reserve(16);
portList.reserve(5);
FilesystemNode dev("/dev/");
dev.getChildren(portList, FilesystemNode::ListMode::All, filter, false);
// Add only those that can be opened
for(const auto& port: portList)
if(isValid(port.getPath()))
if(isPortValid(port.getPath()))
ports.emplace_back(port.getPath());
return ports;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SerialPortMACOS::isValid(const string& port) const
{
// For now, we can only detect whether the port could be opened
// Eventually we may extend this to do more intensive checks
int handle = open(port.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
if(handle > 0)
close(handle);
return handle > 0;
}

View File

@ -69,15 +69,6 @@ class SerialPortMACOS : public SerialPort
*/
StringList portNames() override;
private:
/**
Tests whether this port can be opened, and is a valid
serial port.
@return True if valid, else false
*/
bool isValid(const string& port) const;
private:
// File descriptor for serial connection
int myHandle{0};

View File

@ -102,33 +102,29 @@ StringList SerialPortUNIX::portNames()
{
StringList ports;
// Check if port is valid; for now that means if it can be opened
// Eventually we may extend this to do more intensive checks
auto isPortValid = [](const string& port) {
int handle = open(port.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
if(handle > 0) close(handle);
return handle > 0;
};
// Get all possible devices in the '/dev' directory
FilesystemNode::NameFilter filter = [](const FilesystemNode& node) {
return BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyACM") ||
BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyUSB");
};
FSList portList;
portList.reserve(16);
portList.reserve(5);
FilesystemNode dev("/dev/");
dev.getChildren(portList, FilesystemNode::ListMode::All, filter, false);
// Add only those that can be opened
for(const auto& port: portList)
if(isValid(port.getPath()))
if(isPortValid(port.getPath()))
ports.emplace_back(port.getPath());
return ports;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SerialPortUNIX::isValid(const string& port) const
{
// For now, we can only detect whether the port could be opened
// Eventually we may extend this to do more intensive checks
int handle = open(port.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
if(handle > 0)
close(handle);
return handle > 0;
}

View File

@ -70,15 +70,6 @@ class SerialPortUNIX : public SerialPort
*/
StringList portNames() override;
private:
/**
Tests whether this port can be opened, and is a valid
serial port.
@return True if valid, else false
*/
bool isValid(const string& port) const;
private:
// File descriptor for serial connection
int myHandle{0};