Skip to content

Instantly share code, notes, and snippets.

@satoruhiga
Created September 24, 2015 18:25
Show Gist options
  • Save satoruhiga/25591296f4f481a103bf to your computer and use it in GitHub Desktop.
Save satoruhiga/25591296f4f481a103bf to your computer and use it in GitHub Desktop.
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