Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell arduino yun带usb声卡获取文件数_Shell_Audio_Arduino_Sd Card_Arduino Yun - Fatal编程技术网

Shell arduino yun带usb声卡获取文件数

Shell arduino yun带usb声卡获取文件数,shell,audio,arduino,sd-card,arduino-yun,Shell,Audio,Arduino,Sd Card,Arduino Yun,我有一个项目,在这个项目中,我必须使用arduino播放器,按下一个按钮,随机播放一些声音文件。到目前为止,我可以播放sd卡中的声音,但是我希望根据sd卡中的文件数生成随机数。我需要通过命令shell从草图中读取文件数的帮助 cd /mnt/sda1 ls | wc - l 当我在终点站看到这个时,我得到了答案4,这正是我需要的答案。我想在脚本中运行它,到目前为止我已经有了它,但是它似乎不起作用 d.runShellCommand("ls | wc -l | cd /mnt/sda1");

我有一个项目,在这个项目中,我必须使用arduino播放器,按下一个按钮,随机播放一些声音文件。到目前为止,我可以播放sd卡中的声音,但是我希望根据sd卡中的文件数生成随机数。我需要通过命令shell从草图中读取文件数的帮助

cd /mnt/sda1 
ls | wc - l
当我在终点站看到这个时,我得到了答案4,这正是我需要的答案。我想在脚本中运行它,到目前为止我已经有了它,但是它似乎不起作用

d.runShellCommand("ls | wc -l | cd /mnt/sda1");
result = d.parseInt();
Serial.println(result);
有人能帮我修一下吗


谢谢

您的shell命令中有一些错误。您可以在运行ls时简单地指定目录,而不是通过管道发送到cd命令。例如:

ls | wc -l | cd ~/Documents/
什么也不输出。但是,

ls ~/Documents/ | wc -l
输出“我的文档”文件夹中的文件和文件夹数。 所以这个命令应该可以工作:

d.runShellCommand("ls /mnt/sda1| wc -l");

非常感谢,它工作得很好,我想知道,如果我想获得所有文件的名称并将它们存储在一个数组中,如何实现示例=数组[0]