Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
tellmeUSBSerialDevice.h
#pragma once
#include "ofMain.h"
inline void tellmeUSBSerialDevice()
{
ofDirectory dir;
int n = dir.listDir("/dev");
vector<string> arr;
for (int i = 0; i < n; i++)
{
ofFile f = dir.getFile(i);
if (ofIsStringInString(f.getFileName(), "usbserial")
&& ofIsStringInString(f.getFileName(), "tty"))
{
arr.push_back(f.path());
}
}
if (arr.size())
{
stringstream ss;
for (int i = 0; i < arr.size(); i++)
ss << arr[i] << endl;
ofSystemAlertDialog(ss.str());
}
else
{
ofSystemAlertDialog("usbserial device not found");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment