2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Uduinoの謎の挙動集

Last updated at Posted at 2018-11-19

#なんの記事?
この記事はUduinoに関する謎の挙動を集めたものです。

  • 環境
    • ArduinoIDE 1.8.5
    • Arduino UNO
    • Unity 2.18.2.10f1
    • Uduino 2.1.8
    • MacBookPro

##謎1
Arduinoのスケッチのloop関数内の記述によって、Unityのインスペクタで、UduinoでDiscover ports(以下の写真の青いボタン)を押した時にArduinoを認識するか否かが異なった。

スクリーンショット 2018-11-19 18.08.10.png
//Arduinoのスケッチ
//認識しないもの
void loop()
{
  uduino.update();

  while(isPlay){
    analogWrite(pin, sinwave[indexer]);
    indexer ++;
    delayMicroseconds(50);
    if(indexer ==255){
      indexer = 0;
    }
  }
  
  while(!isPlay){
    analogWrite(pin, 0);
  }
}

//Arduinoのスケッチ
// 認識するもの
void loop()
{
  uduino.update();

  while(isPlay){
    analogWrite(pin, sinwave[indexer]);
    indexer ++;
    delayMicroseconds(50);
    if(indexer ==255){
      indexer = 0;
    }
  }
  
  analogWrite(pin, 0);

}

###備考

  • 原因はわからない
  • どちらもArduinoへの書き込みは成功した

##謎2
Arduinoのシリアルモニタを開いた状態でDiscover portsすると認識されない(以下のエラーコード)。

//Unityのconsoleへのerrorコード
Error on port <color=#2196F3>[/dev/tty.usbmodem143101]</color> : System.IO.IOException: Resource busy  at System.IO.Ports.SerialPortStream.ThrowIOException () [0x0000f] in <93cc5a601cf645d2a15a96c4600351ac>:0   at System.IO.Ports.SerialPortStream..ctor (System.String portName, System.Int32 baudRate, System.Int32 dataBits, System.IO.Ports.Parity parity, System.IO.Ports.StopBits stopBits, System.Boolean dtrEnable, System.Boolean rtsEnable, System.IO.Ports.Handshake handshake, System.Int32 readTimeout, System.Int32 writeTimeout, System.Int32 readBufferSize, System.Int32 writeBufferSize) [0x0001b] in <93cc5a601cf645d2a15a96c4600351ac>:0   at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPortStream..ctor(string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int)  at System.IO.Ports.SerialPort.Open () [0x0006f] in <93cc5a601cf645d2a15a96c4600351ac>:0   at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort.Open()  at Uduino.UduinoDevice_DesktopSerial.Open () [0x0005a] in /Users/kudoryu/github/UduinoTest/Assets/Uduino/Scripts/Boards/Devices/UduinoDevice_DesktopSerial.cs:87 
UnityEngine.Debug:Log(Object)
Uduino.Log:Info(Object, Boolean) (at Assets/Uduino/Scripts/Extra/UduinoDebug.cs:34)
Uduino.UduinoDevice_DesktopSerial:Open() (at Assets/Uduino/Scripts/Boards/Devices/UduinoDevice_DesktopSerial.cs:100)
Uduino.UduinoConnection_DesktopSerial:Discover(String[]) (at Assets/Uduino/Scripts/Boards/Finder/UduinoConnection_DesktopSerial.cs:84)
Uduino.UduinoConnection_DesktopSerial:FindBoards(UduinoManager) (at Assets/Uduino/Scripts/Boards/Finder/UduinoConnection_DesktopSerial.cs:19)
Uduino.UduinoManager:DiscoverPorts() (at Assets/Uduino/Scripts/UduinoManager.cs:453)
Uduino.UduinoManagerEditor:ArduinoSettings() (at Assets/Uduino/Editor/UduinoManagerEditor.cs:808)
Uduino.UduinoManagerEditor:OnInspectorGUI() (at Assets/Uduino/Editor/UduinoManagerEditor.cs:527)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

また、Discover portsして認識に成功した後にArduinoのシリアルモニタを開こうとすると以下のエラーが出て開けない。

//ArduinoIDEへのerrorコード
シリアルポート「/dev/cu.usbmodem143101」が開けません。 (Port busy)

###備考

  • シリアルモニタとUduinoを同時に使うことはできないということ?

##謎3
Uduinoが以下の画像のように接続済の時に、Arduinoに書き込もうとすると、エラーが出てできない。スクリーンショット 2018-11-19 18.52.05.png

//ArduinoIDEへのerrorコード
avrdude: ser_open(): can't open device "/dev/cu.usbmodem143101": Resource busy
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?