Помогите с кодом
- Войдите на сайт для отправки комментариев
Вс, 30/08/2015 - 17:25
прошу помощи, есть arduino nano и ethernet shield 28J60.
помогите адаптировать код под 28J60
у меня ругается на server.print
/////////////////////////////////////////////////////////////////////////////////////////////////////////// #include <SPI.h> #include <Ethernet.h> #include <string.h> char CSSentence[85] = "" ; //string for sentence assembly char MRCSentence[85] = "" ; char MWVSentence[85] = "" ; //string for MVW for sentence assembly char VHWSentence[85] = "" ; //string for VHW sentence assembly char NMEASentence[85] = "" ; //string for NMEA sentence int cs ; //checksum // network configuration. gateway and subnet are optional. // the media access control (ethernet hardware) address for the shield: byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //the IP address for the shield: byte ip[] = { 192, 168, 0, 177 }; // the router's gateway address: byte gateway[] = { 192, 168, 0, 1 }; // the subnet: byte subnet[] = { 255, 255, 255, 0 }; // telnet defaults to port 9999 EthernetServer server = EthernetServer(9999); void setup() { // initialize the ethernet device Ethernet.begin(mac, ip, gateway, subnet); // start listening for clients server.begin(); } void loop() { // analog pin 5 is wind angle // analog pin 4 is wind speed // analog pin 3 is water speed (speedo) // if an incoming client connects, there will be bytes available to read: EthernetClient client = server.available(); /////////////////////////////////// Create MRC Sentence (GPS simulation) strcpy(MRCSentence, "GPRMC,220516,A,5133.82,N,00042.24,W,3.8,4.8,130694,004.2,W"); // MRC sentence is simulated // /////////////////////////////////Create MWV Sentence - Wind Speed and Angle char b[50]="0"; char c[50]="0"; int Z = 0; //Assemble a sentance of the various parts so that we can calculate the proper checksum strcpy(MWVSentence,"PIMWV,"); //The string could be kept the same as what it came in as, but I chose to use the P (prefix for all proprietary devices) and I for instrument //read Pin 5 : Relative wind Direction Z=analogRead(5)/2; // Wind Direction can go from 0 to 360° sprintf(b,"%d",Z); strcat(MWVSentence, b); strcat(MWVSentence, ",R,"); //read Pin 4 : Relative Wind Speed Z=analogRead(4)/2; // Wind speed can go from 0 to 50 knots sprintf(b,"%d",Z/10); //b represent the knots sprintf(c,".%d",(Z-(Z/10)*10)); //c represent the deci knots strcat(MWVSentence, b); strcat(MWVSentence, c); strcat(MWVSentence, ",N,A"); //the atoi command truncated the decimals, might as well stick .0 back on in case something is expecting this field to have a decimal ////////////////////////////////////Create VHW Sentence - Boat speed (water speed)h //read Pin 3 : Boat Speed Z=analogRead(3)/5; // Speed from 0 to 20 Knots - resolution of 0.1 Knots //dtostrf(z, 5, 2, b); //dtostrf(floatVar, minStringWidthIncDecimalPoint, numVarsAfterDecimal, charBuf) strcpy(VHWSentence, "PIVHW,,T,211,M,"); sprintf(b,"%d",Z/10); //b represent the knots sprintf(c,".%d",(Z-(Z/10)*10)); //c represent the deci knots strcat(VHWSentence, b); strcat(VHWSentence, c); strcat(VHWSentence, ",N,0.0,K"); ////////////////////// NMEA to Ethernet ////////////////////////// EtherNMEA(MRCSentence); delay (10); EtherNMEA(MWVSentence); delay (10); EtherNMEA(VHWSentence); delay (300); } // ////////////////////// Functions //////////////////////////////////// String Checksum(char* CSSentence) { cs=0; //clear any old checksum char b[50]="0"; //return b; for (int n=0; n < strlen(CSSentence); n++) { cs ^= CSSentence[n]; //calculates the checksum } sprintf(b,"%02X",cs); return b; } void EtherNMEA (char* NMEASentence) { server.print("$"); // Assemble the final message and send it out the serial port server.print(NMEASentence); server.print("*"); server.print(Checksum(NMEASentence)); // Call Checksum function server.println(); }
источник
http://jdelecour.over-blog.com/2013/10/centrale-de-navigation-low-cost-avec-arduino.html
ругается на server.print если использую эту библиотеку
http://www.himix.lt/arduino/arduino-nano-and-nano-ethernet-shield-using-...
А чего говорит-то? Нам самим догадываться? Или ругается так, в приличном месте повторять нельзя?