Hi. I found this while searching for a project to make my own WiFi MPG / hardware interface for LinuxCNC. Thank you for providing the information.
I am going over the Arduino code and am a little confused. Before I test the project, I wanted to modify it for my own needs and be certain the code was tidy. There are functions in the code that are a little inefficient, and some code that is executing that probably should not.
Code:
void encodeTx()
{
Udp.beginPacket(ipRemote, portRemote);
uint8_t v = 0;
for(int c = 0; c < 6; c++)
{
adcResult = analogRead(c);
sprintf(ReplyBuffer,"%4d", adcResult);
Udp.write(ReplyBuffer);
Udp.write(",");
int dummy = c;
if (c >= iOutputPins)
{
int moredummy = c;
if(digitalRead(pinMap[c])){
v |= (1<<c);
}
}
}
This is reading only analog values from pins 0-5, and sends the data out. 1/2 way through the loop, it will read digital input values, and do nothing with them, storing to "V" which is never used.
The decodeRX function also wants to set the pin-modes, after the setup function each and every time it receives a UDP packet. Not sure what the purpose of that was, since it would take some pretty sophisticated hardware to process data that could swap input & output pins at runtime.
Just curious....