Hi guys, i have arduino yun.
I connected a USB key on Arduino (in USB host)
I want to run arduino only if the usb stick has the id eg 0123, (using lsusb?) can you help me please?
Thank you
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 058f:6254 Alcor Micro Corp. USB Hub
Bus 001 Device 003: ID 058f:6366 Alcor Micro Corp. Multi Flash Reader
Bus 001 Device 004: ID 18a5:0302 Verbatim, Ltd Flash Drive
i want parse this id:
Bus 001 Device 004: ID 18a5:0302 Verbatim, Ltd Flash Drive
nano test.sh
#!/bin/sh
if (lsusb |grep -q "18a5:0302")
then
# code if found
echo "Found"
else
# code if not found
echo "N/A"
fi
grep --help
...
-q Quiet. Return 0 if PATTERN is found, 1 otherwisels
...
Hi , thank you but i want include this code in my sketch arduino... is possible?
Thank you… i have tried this sketch…
#include <Process.h>
void setup() {
Bridge.begin();
Serial.begin(9600);
while (!Serial);
USBKey();
}
void loop() {
}
void USBKey() {
Process p;
p.begin("lsusb");
p.addParameter("|grep -q \"18a5:0302\"");
p.run();
while (p.available()>0) {
char c = p.read();
Serial.print(c);
}
Serial.flush();
}
but console il empty…how to solve?
nano /mnt/sda1/test.sh
or if you have no MicroSD
nano /root/test.sh
chmod 755 /mnt/sda1/test.sh
Process p;
p.begin("/mnt/sda1/test.sh");
p.run();
while (p.available()>0) {
char c = p.read();
Serial.print(c);
}
always test function of it first at console
/mnt/sda1/test.sh