Windows 7에서 Arduino 1.5.3으로 스케치를 업로드 한 인텔 갈릴레오에 이더넷으로 연결된 VS2012를 사용하고 있습니다. 최종 목표는 이더넷 케이블을 통해 모터를 제어하는 것이지만 두 프로그램 간의 간단한 연결을 설정할 수는 없습니다. 이더넷 넷이나 Udp 또는 네트워크에 대한 경험이 없으므로 불합리한 금액을 상세하게 기재하십시오.인텔 갈릴레오를 이더넷 케이블을 통해 C#에 연결하려고 시도했습니다.
이#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: [email protected] 12/30/2008
byte mac[] = { 0X98 , 0x4F, 0xEE, 0x01, 0x54, 0xB3};
IPAddress ip(192,168,1,177);
unsigned int localPort = 8888;
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged"; // a string to send back
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort);
Serial.begin(9600);
}
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if(packetSize)
{
Serial.print("Received packet of size ");
Serial.println(packetSize);
Serial.print("From ");
IPAddress remote = Udp.remoteIP();
for (int i =0; i < 4; i++)
{
Serial.print(remote[i], DEC);
if (i < 3)
{
Serial.print(".");
}
}
Serial.print(", port ");
Serial.println(Udp.remotePort());
// read the packet into packetBufffer
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
Serial.println("Contents:");
Serial.println(packetBuffer);
// send a reply, to the IP address and port that sent us the packet we received
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
}
delay(10);
}
첫째, 다음, 갈릴레오 오픈 스케치를 업로드 : 여기
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TemperatureArduinoReader
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
byte[] packetData = System.Text.ASCIIEncoding.ASCII.GetBytes("hello World");
string IP = "192.168.1.177";
//"127.0.0.1";
int port = 8888;
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(IP), port);
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
client.SendTo(packetData, ep);
}
}
}
는 아두 이노 webstite에서 촬영 아두 이노에 내 코드입니다 : 여기
은 C#을 내 코드입니다 직렬, 다음 C# 프로그램을 실행하지만 아무것도 직렬에 나타납니다.
나는 며칠 동안 이것을 알아 내려고 벽에 머리를 때렸다. IP 주소와 그 밖의 모든 조합을 시도했지만, 이제 당신의 도움을 찾고 있습니다.
감사합니다.