Pages: [1] 2   Go Down
Author Topic: Problem running Gobetwino  (Read 3128 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What code do you have on the Arduino?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have one of the sketches that comes in the samples folder of gobetwino:

Code:
// 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.
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
 while(!Serial){
    ;
  };
« Last Edit: December 25, 2012, 04:47:14 pm by MikMo » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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....
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?

Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thi is the VB.net code that opens the serial port in GoBetwino:

Code:
  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
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16520
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

http://arduino.cc/en/Serial/IfSerial

Lefty
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is my C# callback to open the serial port:
Code:
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:
Quote
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]#
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmmm.

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

Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Pages: [1] 2   Go Up
Jump to: