Cos'è ElectroYou | Login Iscriviti

ElectroYou - la comunità dei professionisti del mondo elettrico

Errore processing

Progetti, interfacciamento, discussioni varie su questa piattaforma.

Moderatori: Foto UtenteWALTERmwp, Foto Utentexyz

0
voti

[1] Errore processing

Messaggioda Foto Utentepapa10 » 13 apr 2017, 18:29

In un progetto di un ECG in cui sto lavorando, nella parte processing escono alcuni errori:
Codice: Seleziona tutto
void setup() {
  Serial.begin(9600);
  pinMode(10, INPUT);
  pinMode(11, INPUT);
}

void loop() {
  if ((digitalRead(10) == 1) || (digitalRead(11) == 1)) {
    Serial.println('!');
  }
  else {
    Serial.println(analogRead(A0));
  }
  delay(1);
}

import processing.serial.*;

Serial myPort;       
int xPos = 1;         
float height_old = 0;
float height_new = 0;
float inByte = 0;

void setup () {
  size(1000, 400);
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[0], 9600);
  myPort.bufferUntil('\n');
  background(0xff);
}

void draw () {
}

void serialEvent (Serial myPort) {
  String inString = myPort.readStringUntil('\n');

  if (inString != null) {
    inString = trim(inString);
    if (inString.equals("!")) {
      stroke(0, 0, 0xff);
      inByte = 512;
    }
    else {
      stroke(0xff, 0, 0);
      inByte = float(inString);
     }
     inByte = map(inByte, 0, 1023, 0, height);
     height_new = height - inByte;
     line(xPos - 1, height_old, xPos, height_new);
     height_old = height_new;
      if (xPos >= width) {
        xPos = 0;
        background(0xff);
      }
      else {
        xPos++;
      }
  }
}

Mi da’ i seguenti errori
Codice: Seleziona tutto
Syntax error maybe a missing right parenthesis?

poi in error
Codice: Seleziona tutto
the variable"gt" does not exist         riga 11
type string[] of the last argument to method printl(obyect....) doesn't exactly match the vararg parameter                                    riga 37
Syntax error on tokens,delete these tokens    riga 37

alla console
Codice: Seleziona tutto
  expecting RPAREN,found;

Cosa devo fare?.V ringrazio e le invio auguri di buona Pasqua
Ultima modifica di Foto Utentewall87 il 13 apr 2017, 18:52, modificato 1 volta in totale.
Motivazione: Riscritto titolo in minuscolo
Avatar utente
Foto Utentepapa10
71 1 3 4
Frequentatore
Frequentatore
 
Messaggi: 248
Iscritto il: 20 ott 2011, 17:11

1
voti

[2] Re: Errore processing

Messaggioda Foto Utentesimo85 » 13 apr 2017, 20:47

Questo è sbagliato.

Codice: Seleziona tutto
if (xPos >= width)
{
   xPos = 0;
   background(0xff);
}

Forse il ; dovrebbe essere un = ? ;-)
Avatar utente
Foto Utentesimo85
30,9k 7 12 13
Disattivato su sua richiesta
 
Messaggi: 9927
Iscritto il: 30 ago 2010, 4:59

3
voti

[3] Re: Errore processing

Messaggioda Foto Utentexyz » 13 apr 2017, 22:09

Sostituisci la sequenza ">" nel carattere ">". Quello è codice C++ non una pagina HTML :-)

P.S. Aspetta la prima parte è codice C++ credo per Arduino ma le seconda parte non è congrua con la prima parte è codice in Java. E' impossibile scrive in contemporanea un codice sorgente in due linguaggi differenti :-)
Avatar utente
Foto Utentexyz
6.864 2 4 6
G.Master EY
G.Master EY
 
Messaggi: 1778
Iscritto il: 5 dic 2009, 18:37
Località: Italy Turin

0
voti

[4] Re: Errore processing

Messaggioda Foto UtenteTardoFreak » 13 apr 2017, 22:29

Ti riferisci al fatto che ha la direttiva import?
Quella è stata introdotta dalla minchiasoft e, se non ricordo male, il gcc non la supporta più.

P.S.: ho solo dato uno sguardo veloce ...
Avatar utente
Foto UtenteTardoFreak
73,9k 8 12 13
-EY Legend-
-EY Legend-
 
Messaggi: 15754
Iscritto il: 16 dic 2009, 11:10
Località: Torino - 3° pianeta del Sistema Solare

0
voti

[5] Re: Errore processing

Messaggioda Foto Utentesimo85 » 13 apr 2017, 22:33

xyz ha scritto:Sostituisci la sequenza ">" nel carattere ">". Quello è codice C++ non una pagina HTML :-)

Noooooooooooooooo ! :mrgreen:
Avatar utente
Foto Utentesimo85
30,9k 7 12 13
Disattivato su sua richiesta
 
Messaggi: 9927
Iscritto il: 30 ago 2010, 4:59

1
voti

[6] Re: Errore processing

Messaggioda Foto Utentexyz » 13 apr 2017, 22:35

Il GCC per il C++ non ha mai avuto import, non fa parte dello standard ANSI, neanche nell'ultimo standard approvato.

Comunque da vecchio programmatore in Java riconosco il codice in Java (Serial, String, non usa == ma equals, e altro) :-)
Avatar utente
Foto Utentexyz
6.864 2 4 6
G.Master EY
G.Master EY
 
Messaggi: 1778
Iscritto il: 5 dic 2009, 18:37
Località: Italy Turin

0
voti

[7] Re: Errore processing

Messaggioda Foto UtenteTardoFreak » 13 apr 2017, 22:37

Ho guardato meglio: è vero ho visto un .equals e questo dice tutto. :ok:
Punto meritato.
Avatar utente
Foto UtenteTardoFreak
73,9k 8 12 13
-EY Legend-
-EY Legend-
 
Messaggi: 15754
Iscritto il: 16 dic 2009, 11:10
Località: Torino - 3° pianeta del Sistema Solare

0
voti

[8] Re: Errore processing

Messaggioda Foto Utentepapa10 » 14 apr 2017, 19:30

e allora cosa devo fare?
Avatar utente
Foto Utentepapa10
71 1 3 4
Frequentatore
Frequentatore
 
Messaggi: 248
Iscritto il: 20 ott 2011, 17:11

0
voti

[9] Re: Errore processing

Messaggioda Foto Utentesimo85 » 14 apr 2017, 19:36

Ma lo hai letto il post di Foto Utentexyz ?
Avatar utente
Foto Utentesimo85
30,9k 7 12 13
Disattivato su sua richiesta
 
Messaggi: 9927
Iscritto il: 30 ago 2010, 4:59

1
voti

[10] Re: Errore processing

Messaggioda Foto Utentepapa10 » 16 apr 2017, 11:20

Comunque ho risolto il problema da solo,vi ringrazio e vi auguro una felice e Santa Pasqua:

Codice: Seleziona tutto
import processing.serial.*;

Serial myPort;       
int xPos = 1;         
float height_old = 0;
float height_new = 0;
float inByte = 0;

void setup () {
  size(1000, 400);
println ((Object []) Serial.list ());

  myPort = new Serial(this, Serial.list()[0], 9600);
  myPort.bufferUntil('\n');
  background(0xff);
}

void draw () {
}

void serialEvent (Serial myPort) {
  String inString = myPort.readStringUntil('\n');

  if (inString != null) {
    inString = trim(inString);
    if (inString.equals("!")) {
      stroke(0, 0, 0xff);
      inByte = 512;
    }
    else {
      stroke(0xff, 0, 0);
      inByte = float(inString);
     }
     inByte = map(inByte, 0, 1023, 0, height);
     height_new = height - inByte;
     line(xPos - 1, height_old, xPos, height_new);
     height_old = height_new;
      if (xPos >= width) {
        xPos = 0;
        background(0xff);
      }
      else {
        xPos++;
      }
  }
}
Avatar utente
Foto Utentepapa10
71 1 3 4
Frequentatore
Frequentatore
 
Messaggi: 248
Iscritto il: 20 ott 2011, 17:11


Torna a Arduino

Chi c’è in linea

Visitano il forum: Nessuno e 2 ospiti