ofSerial listDevices with usable output

Hi,

I’ve searched for this on the forum, but I couldn’t find anyone asking for this:

Wouldn’t it make sense to add a function to ofSerial that lists the serial ports and outputs a vector or array of the ports? I use this quite often when I need to be able to select the serial port at runtime (eg.: using OF to talk to different Arduino’s… )

example (OSX):

  
  
vector <string> ofSerial::getDevices(){  
	vector <string> vec;  
	  
	DIR *dir;  
	struct dirent *entry;  
	dir = opendir("/dev");  
	string str			= "";  
	string device		= "";  
	int deviceCount		= 0;  
	  
	if (dir == NULL){  
		ofLog(OF_LOG_ERROR,"ofxSerial: error listing devices in /dev");  
	} else {  
		ofLog(OF_LOG_NOTICE,"ofxSerial: listing devices");  
		while ((entry = readdir(dir)) != NULL){  
			str = (char *)entry->d_name;  
			if( str.substr(0,3) == "cu." || str.substr(0,4) == "tty." ){  
				ofLog(OF_LOG_NOTICE,"device %i - %s", deviceCount, str.c_str());  
				vec.push_back(str);  
				deviceCount++;  
			}  
		}  
	}  
	return vec;  
}