I want to be able to use gobetwino for logging some data to excel and plot graphs.
I followed the instructions in the tutorial pdf and in the sample pdf, namelly the creation of CPTEST and LOGTEST. I have read this topic too and folowed the instructions contained in it:
I have one of the sketches that comes in the samples folder of gobetwino:
// This sketch demonstrates the use of the Gobetwino commandtypes LGFIL and CPFIL
int serInLen = 25;
char serInString[25];
int logValue1=0;
int logValue2=0;
int logValue3=0;
int result;
void setup()
{
// Setup serial comm. Initialize random function.
Serial.begin(9600);
while(!Serial){
;
};
randomSeed(analogRead(0));
delay(5000);
// Use the CPTEST copy file command to make a copy of a new empty logfile
Serial.println("#S|CPTEST|[]#");
readSerialString(serInString,1000);
// There ought to be a check here for a non 0 return value indicating an error and some error handeling
}
void loop()
{
//Create some random values to log to a file on the PC. This could be sensor readings or whatever
//but for this example it's just 3 random values
logValue1= random(0,1000);
logValue2= random(0,1000);
logValue3= random(0,1000);
logData(logValue1,logValue2,logValue3);
delay(500);
}
// Send the LOGTEST command to Gobetwino the 3 random values are seperated by semicolons
void logData( int value1, int value2, int value3)
{
char buffer[5];
Serial.print("#S|LOGTEST|[");
Serial.print(itoa((value1), buffer, 10));
Serial.print(";");
Serial.print(itoa((value2), buffer, 10));
Serial.print(";");
Serial.print(itoa((value3), buffer, 10));
Serial.println("]#");
readSerialString(serInString,1000);
// There ought to be a check here for a non 0 return value indicating an error and some error handeling
}
//read a string from the serial and store it in an array
//you must supply the array variable - return if timeOut ms passes before the sting is read
void readSerialString (char *strArray,long timeOut)
{
long startTime=millis();
int i;
while (!Serial.available()) {
if (millis()-startTime >= timeOut) {
return;
}
}
while (Serial.available() && i < serInLen) {
strArray[i] = Serial.read();
i++;
}
}
It had a pde extension but the frist time i opened it in Arduino environment asked to change to ino extension.
I installed GoBetwino, set up the necessary commands, and compiled and linked that code for the Mega. GoBetwino caught all the serial data, and logged it as it was supposed to.
I then changed the board type to Leonardo, and connected the Leonardo. I uploaded the sketch, started GoBetwino and changed the com port to the correct port. No communication with the Leonardo appears in the top window. Opening the Serial Monitor fails, because the COM port (COM10) is in use.
In my case i think gobetwino comunicates with Leonardo, since the only message it gives is: Serial port : COM9 opened at 9600 baud
All that that means is that GoBetwino connected to the serial port. It isn't clear that any communication actually takes place.
If MikMo doesn't get back to us today, I'll try my C# application, to see if the Leonardo and PC are actually communicating. Right now, I'd suspect that there is something about the COM port setup that isn't what the Leonardo expects.
Thi is the VB.net code that opens the serial port in GoBetwino:
Public Sub serialPortOpen()
'Configure and open the serial port
'If the port is already open, close it first
If serialPort.IsOpen Then
serialPort.Close()
End If
Try
With serialPort
.PortName = settings.getSetting("serialPortName")
.BaudRate = CInt(settings.getSetting("serialPortbaud"))
'WARNING DO NOT CHANGE BELOW SETTINGS FOR USE WITH ARDUINO
.Parity = CInt(settings.getSetting("serialPortParity"))
.DataBits = CInt(settings.getSetting("serialPortDataBits"))
.StopBits = CInt(settings.getSetting("serialPortStopBits"))
.Handshake = CInt(settings.getSetting("serialPortHandShake"))
'WARNING END :-)
.Encoding = System.Text.Encoding.ASCII
.NewLine = Chr(13) + Chr(10)
End With
'Open the port and clear any junck in the input buffer
serialPort.Open()
serialPort.DiscardInBuffer()
statusAndLog("Serial port : " + serialPort.PortName + " opened at " + settings.getSetting("serialPortbaud") + " baud")
Catch Ex As Exception
statusAndLog("Can not open serial port : " + serialPort.PortName)
statusAndLog(Ex.Message)
End Try
End Sub
Not yet. Lets see if we can't get GoBetwino working first. If so, then the change that needs to be made to GoBetwino probably needs to be made to the other classes you are having issues with.
MikMo sent me a link to the new version of GoBetwino to test. It works with the Mega, the Duemilanove, AND the Leonardo. I'm sure he'll be making it available for all, soon.