- Netduino Forums
- → Runner's Content
Runner's Content
There have been 14 items by Runner (Search limited from 06-June 23)
#40930 Multiple Netduinos within one local Network
Posted by Runner on 04 December 2012 - 11:43 AM in Netduino Plus 2 (and Netduino Plus 1)
#40351 Multiple Netduinos within one local Network
Posted by Runner on 28 November 2012 - 05:55 AM in Netduino Plus 2 (and Netduino Plus 1)
Sorry was ill the last days.
Here some code:
System.Net.Sockets.Socket LVSocket = null; System.Net.IPEndPoint LVEndpoint = null; System.Net.Sockets.Socket uCSocket = null; System.Net.IPEndPoint uCEndpoint = null; // Path of the init File at the Sd Card System.String Path = @"\SD\Config_INIT.txt"; // DEFAULT values if SD Card is not found or not inserted // SETTINGS for Netduino #1 System.String LabViewIP = "192.168.1.20"; System.Int32 NetworkPort = 49001; System.String NetduinoIP = "192.168.001.21"; // SETTINGS for Netduino #2 // System.String LabViewIP = "192.168.1.20"; // System.Int32 NetworkPort = 49002; // System.String NetduinoIP = "192.168.001.22";
The program checks for an config file at the SD Card (works fine)
If no SD Card detected it will continue with:
System.Net.IPAddress IPLabview = System.Net.IPAddress.Parse(LabViewIP); System.Net.IPAddress IPNetduino = System.Net.IPAddress.Parse(NetduinoIP); Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP(NetduinoIP, "255.255.255.0", "192.168.0.0"); if (uCEndpoint == null) { uCSocket = UDPConnector.RecieveSocket(uCSocket); uCEndpoint = UDPConnector.RecievePoint(uCSocket, uCEndpoint, IPNetduino, NetworkPort); } if (LVSocket == null) { LVSocket = UDPConnector.SendSocket(LVSocket); LVEndpoint = UDPConnector.SendPoint(LVSocket, LVEndpoint, IPLabview, NetworkPort); } byte[] Recieved = UDPConnector.getMessage(uCSocket);
BTW I´m using CAT5 cables
#41010 Multiple Netduinos within one local Network
Posted by Runner on 05 December 2012 - 08:06 AM in Netduino Plus 2 (and Netduino Plus 1)
#39986 Multiple Netduinos within one local Network
Posted by Runner on 23 November 2012 - 09:28 AM in Netduino Plus 2 (and Netduino Plus 1)
#39985 Multiple Netduinos within one local Network
Posted by Runner on 23 November 2012 - 08:24 AM in Netduino Plus 2 (and Netduino Plus 1)
#39993 Multiple Netduinos within one local Network
Posted by Runner on 23 November 2012 - 11:16 AM in Netduino Plus 2 (and Netduino Plus 1)
#39978 Multiple Netduinos within one local Network
Posted by Runner on 23 November 2012 - 07:45 AM in Netduino Plus 2 (and Netduino Plus 1)
#24602 High Speed Ethernet
Posted by Runner on 23 February 2012 - 09:10 AM in Netduino Plus 2 (and Netduino Plus 1)
Glad I could be of help! So did you use interop or just optimized the managed/C# code?
Unfortunately i have to admit that this was the easiest way:
took my brain out of the desk and used it for programming.. :-)
my code was full of converting functions...
e.g.:
i recieved a byte array converted it to a string...
then i separated the string to a string array and converted it again to byte or int or something else...
same procedure for sending data...
i don´t know why i have done things like that...
after all i have to laugh about the mess of code i´ve created.. :-)
therefore the warning: Do not use my code!
#24341 High Speed Ethernet
Posted by Runner on 17 February 2012 - 01:55 PM in Netduino Plus 2 (and Netduino Plus 1)
For sending the Data:
public static void sendMessage(string message, Socket send, IPEndPoint Endpoint) { byte[] bytes = Encoding.UTF8.GetBytes(message); send.Send(bytes); }
For setting up the connection:
// Checking if there is allready a socket public static Socket socketUDP(Socket SOCK) { if (SOCK==null) { Socket send = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); // build socket return send; // take new one } else return SOCK; // use old socket } public static IPEndPoint Point(Socket send, IPEndPoint IPEND) { if (IPEND==null) { IPEndPoint Endpoint = new IPEndPoint(IPAddress.Parse("192.168.5.10"), 49000); send.Connect(Endpoint); return Endpoint; } else return IPEND; }
and at last the measurement..
while(true) { Counter++; double PINDATA= GPIO_PIN_A0.Read(); double value = (PINDATA* maxVoltage) / maxADCValue; string Measured= value.ToString("f6"); DATAOUT= DATAOUT+ "+" + Measured; // packing data seperated by "+" string Order= NDPConnect.getMessage(uCSocket); //checking for new orders if (Order.Length != 0) { NDPConnect.sendMessage(DATAOUT, LVSocket, LVEndpoint); // send data immdiately DATAOUT= ""; return Order; // go to recieved case } if (Counter >= 20) { Counter= 0; NDPConnect.sendMessage(DATAOUT, LVSocket, LVEndpoint); // send data DATAOUT= ""; return "WAIT@ALL#"; // go to wait case }; }
#24598 High Speed Ethernet
Posted by Runner on 23 February 2012 - 06:46 AM in Netduino Plus 2 (and Netduino Plus 1)
#24448 High Speed Ethernet
Posted by Runner on 20 February 2012 - 06:32 AM in Netduino Plus 2 (and Netduino Plus 1)
#24611 High Speed Ethernet
Posted by Runner on 23 February 2012 - 03:13 PM in Netduino Plus 2 (and Netduino Plus 1)
#24339 High Speed Ethernet
Posted by Runner on 17 February 2012 - 01:40 PM in Netduino Plus 2 (and Netduino Plus 1)
Attached Files
- Wireshark.bmp 717.24KB 35 downloads
#24636 High Speed Ethernet
Posted by Runner on 24 February 2012 - 05:51 AM in Netduino Plus 2 (and Netduino Plus 1)
// setup for I2C ushort Address = 0x80 >> 1; int ICSpeed = 400; var Duino = new Microsoft.SPOT.Hardware.I2CDevice(new Microsoft.SPOT.Hardware.I2CDevice.Configuration(Address, ICSpeed)); var commands = new Microsoft.SPOT.Hardware.I2CDevice.I2CTransaction[] { Microsoft.SPOT.Hardware.I2CDevice.CreateWriteTransaction(Register), //Order to read out the INA226 Microsoft.SPOT.Hardware.I2CDevice.CreateReadTransaction(buffer), // Recieve answer from INA226 };
// routine for reading out the I2C sensing device while (Shunt < ClusterSize) { Duino.Execute(commands, 1); // I2C transmittion DATAOUT[Shunt++] = buffer[0]; DATAOUT[Shunt++] = buffer[1]; }after the .Execute command there is the pause....
or takes the netduino so much time to write the two byte from buffer to dataout?
- Netduino Forums
- → Runner's Content
- Privacy Policy