Problem running Gobetwino

Hello.

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:

http://arduino.cc/forum/index.php/topic,132419.15.html

But i cant get it working...

To be more specific and helpful here is the steps i followed:

  1. Downloaded and unziped gobetwino to C:/gobtwino location;

  2. In Settings i choose COM 9 at 9600 baud, that is the port i have for working with arduino

  3. In Settings i have level 3 message status, so i guess it shows up every message.

  4. I created the commands CPTEST and LOGTEST and linked it to the respective example csv files.

  5. I restarted gobetwino to make the settings and comand updates valid.

  6. have closed gobetwino window;

  7. Uploaded the sketch to Leonardo unsing COM 9 (since i tried another time before this: the serial monitor prints CPTEST and LOGTEST random values)

  8. Started gobetwino and all i get is this in status messages: 24-12-2012 11:53:15 Serial port : COM9 opened at 9600 baud

Important informations:

I use window 7 machine and an Arduino Leonardo

in setup() function i use: While(!serial){ ;};

Any help would be great.

Thanks.

Another thing:

Sometimes when i close gobetwino i get an error message that "the program quited working" and that windows is looking for a solution for this.

Another information, and dont know if this is important, every time i open gobetwino the RX led in Leonardo lights up.

What code do you have on the Arduino?

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.

What is the purpose of this code, which i believe is not part of the supplied sample code :

  while(!Serial){
    ;
  };

What is the purpose of this code, which i believe is not part of the supplied sample code :

On the Leonardo, it waits for the serial port to be ready. On other models, it does nothing.

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.

MikMo, what's going on? Any ideas?

In my case i think gobetwino comunicates with Leonardo, since the only message it gives is: Serial port : COM9 opened at 9600 baud

But nothing more than that....

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.

I'm afraid i have no idea right now.

I do not have a Leonardo to try out.

Is there any known difference in the serial communication between the UNO and the Leonardo ?

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

MikMo:
I'm afraid i have no idea right now.

I do not have a Leonardo to try out.

Is there any known difference in the serial communication between the UNO and the Leonardo ?

Must be as there seems to have been a new serial function added in version 1.0.1 to support the Leonardo:

Lefty

This is my C# callback to open the serial port:

		private void btnConnect_Click(object sender, EventArgs e)
		{
			System.ComponentModel.IContainer components = 
				new System.ComponentModel.Container();
			port = new System.IO.Ports.SerialPort(components);
			port.PortName = comPort.SelectedItem.ToString();
			port.BaudRate = Int32.Parse(baudRate.SelectedItem.ToString());
			port.DtrEnable = true;
			port.ReadTimeout = 5000;
			port.WriteTimeout = 500;
			port.Open();

			readThread = new Thread(new ThreadStart(this.Read));
			readThread.Start();
			this.hardWorker.RunWorkerAsync();

			btnConnect.Text = "<Connected>";

			btnConnect.Enabled = false;
			comPort.Enabled = false;
			sendBtn.Enabled = true;
		}

With this, the C# application is able to receive data sent by the Arduino:

Text: #S|CPTEST|[]#
Text: #S|LOGTEST|[851;349;305]#
Text: #S|LOGTEST|[172;976;867]#
Text: #S|LOGTEST|[311;756;941]#
Text: #S|LOGTEST|[917;637;713]#
Text: #S|LOGTEST|[933;707;769]#
Text: #S|LOGTEST|[112;701;456]#
Text: #S|LOGTEST|[837;12;744]#

Hmmm.

I wonder if it is the dtr enable that makes it work ?

I wonder if it is the dtr enable that makes it work ?

Worth a try. I'll test it for you, if you create a new executable.

Guys i am starting to be somehow frustrated with this Leonardo board :frowning:

Tried to run MegunoLink, can t get live data...

Tried to run Fetch, cant get live data...

Don t know if this deserves a new thread....

Thanks for your help.

Don t know if this deserves a new thread....

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.

You can then create new topics for each of them.

i will try to put the dtr enable in gobetwino, just give me a tiny little time :slight_smile:

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.

Ok so it was the DTR that should be enabled.

Thanks for testing Paul :slight_smile:

I will repackage GoBetwino ASAP.

There is also a little bug that was discovered recently that i will fix.