Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.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
c#/Arduino SerialPort.read()为空_C#_Arduino - Fatal编程技术网

c#/Arduino SerialPort.read()为空

c#/Arduino SerialPort.read()为空,c#,arduino,C#,Arduino,我正试图从我的arduino中检索一些数据 我在我的arduino上使用这个: Serial.println((String)animation); 这在我的c#应用程序中 log.WriteEntry(message, EventLogEntryType.Information); port.Write(message.Replace(Environment.NewLine, "")); byte[] buffer = new byte[1024]; port.Read(buffer,

我正试图从我的arduino中检索一些数据

我在我的arduino上使用这个:

Serial.println((String)animation);
这在我的c#应用程序中

log.WriteEntry(message, EventLogEntryType.Information);

port.Write(message.Replace(Environment.NewLine, ""));

byte[] buffer = new byte[1024];

port.Read(buffer, 0, buffer.Length);

message = Encoding.ASCII.GetString(buffer).Replace("\0", "");

log.WriteEntry(message, EventLogEntryType.Information);
我还使用
.ReadTo(NewLine thing)进行了尝试
.ReadLine()


我的消息总是这样:

不幸的是,将整数(或
动画
的任何类型)转换为字符串实际上不会产生文本表示。尝试
Serial.println(动画)
Serial.println(字符串(动画))不幸的是,将整数(或任何类型的
动画
转换为字符串)转换为字符串实际上不会产生文本表示。尝试
Serial.println(动画)
Serial.println(字符串(动画))