Debug arudino runtime exceptions.
This commit is contained in:
parent
2304c6e338
commit
c4bdac2e60
4 changed files with 38 additions and 12 deletions
|
@ -104,19 +104,27 @@ void findServer()
|
|||
char* datagramStr = (char*)datagramBuffer;
|
||||
|
||||
// Find the positions of the key characters
|
||||
//int atPos = getPosition(datagramStr, datagramSize, '@');
|
||||
//int colonPos = getPosition(datagramStr, datagramSize, ':');
|
||||
int atPos = findChar(datagramStr, '@');
|
||||
int colonPos = findChar(datagramStr, ':');
|
||||
|
||||
char* role;
|
||||
char* serverIp;
|
||||
char* portNumberText;
|
||||
char role[7];
|
||||
char serverIp[16];
|
||||
char portNumberText[7];
|
||||
memset(role, '\0', 7);
|
||||
memset(serverIp, '\0', 16);
|
||||
memset(portNumberText, '\0', 7);
|
||||
|
||||
strncpy(role, datagramStr, atPos);
|
||||
strncpy(serverIp, datagramStr + atPos + 1, colonPos);
|
||||
strncpy(portNumberText, datagramStr + colonPos + 1, datagramSize - 1);
|
||||
strncpy(role, datagramStr, atPos); Serial.print("R: "); Serial.println(role);
|
||||
strncpy(serverIp, datagramStr + atPos + 1, colonPos - atPos - 1);
|
||||
strncpy(portNumberText, datagramStr + colonPos + 1, datagramSize - colonPos - 1);
|
||||
|
||||
Serial.println("complete.");
|
||||
|
||||
Serial.print("atPos: "); Serial.println(atPos);
|
||||
Serial.print("colonPos: "); Serial.println(colonPos);
|
||||
|
||||
Serial.print("Role: "); Serial.print(role); Serial.print(" ");
|
||||
Serial.print("Remote IP: "); Serial.print(serverIp); Serial.print(" ");
|
||||
Serial.print("Port number: "); Serial.print(portNumberText);
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
#include <string.h>
|
||||
//#include <string.h>
|
||||
//#include <algorithm>
|
||||
|
||||
|
||||
int findChar(char* str, char targetChar)
|
||||
{
|
||||
for(int i = 0; strcmp(&str[i], "\0") == 0; i++) {
|
||||
for(int i = 0; str[i] != '\0'; i++) {
|
||||
if(str[i] == targetChar) return i;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
int getPosition(const char *array, size_t size, char c)
|
||||
{
|
||||
const char* end = array + size;
|
||||
const char* match = std::find(array, end, c);
|
||||
return (end == match)? -1 : (match-array);
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -8,3 +8,6 @@
|
|||
*/
|
||||
|
||||
int findChar(char* str, char targetChar);
|
||||
|
||||
int getPosition(const char *array, int size, char c);
|
||||
|
||||
|
|
|
@ -2,8 +2,13 @@
|
|||
|
||||
A combination of a C# server and an arduino program that allows the control of a Hull Pixelbot.
|
||||
|
||||
## Credits
|
||||
- Debugging:
|
||||
- Andrew C, Karen van Eck, Mike C
|
||||
|
||||
## Useful Links
|
||||
### For Multicast networkinterface blog post
|
||||
- [NetworkInterface class](https://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface(v=vs.110).aspx))
|
||||
- [Sockoverflow answer](http://stackoverflow.com/questions/2192548/specifying-what-network-interface-an-udp-multicast-should-go-to-in-net)
|
||||
- [IPv4InterfaceProperties](https://msdn.microsoft.com/en-us/library/system.net.networkinformation.ipv4interfaceproperties(v=vs.110).aspx)
|
||||
|
||||
|
|
Reference in a new issue