print result of EEPROM.read() to serial

I'm having difficulty getting the result of my EEPROM.read() function to print to the serial monitor and was looking for some advice. I've posted the sketch below and the code in question would be under the parse() function.

I've tried assigning the result to a variable (ie eeread = EEPROM.read(rvalue); then Serial.print(eeread). but I don't see anything on the screen. I have a feeling it has something to do with the function being type void, but honestly, I'm new enough to Arduino and programming, I really don't have a clue what to look at.

#include <EEPROM.h>

const byte chars = 32;
char received[chars];
char temp[chars]; //temp to use for parsing

char operation[chars]= {0};
int rvalue;
int wadd;
int wval;

bool NewInput = false;

void setup() {
  Serial.begin(9600);
  Serial.println("This program reads the value stored in memory addresses(0-1023), or writes a value(0-255) to a memory address");
  Serial.println("Expected format for read is -- read address");
  Serial.println("Expected format for write is -- write address value");
  
 
}

void loop() {
 
  recStEdMarks();
  if (NewInput == true) {
    strcpy(temp, received);
    parse();
    viewparsed();
    NewInput = false;
  }
      
  
}

void recStEdMarks(){
  static bool recIP = false;
  static byte next = 0;
  char startmk = ' ';
  char endmk = ' ';
  char r;

  while (Serial.available() > 0 && NewInput == false){
    r = Serial.read();
    if (recIP == true) {
      if (r != endmk) {
        received[next] = r;
        next++;
        if (next >= chars) {
          next = chars - 1;
        }
      }
      else {
        received[next] = '\0'; //end the string
        recIP = false;
        next = 0;
        NewInput = true;
      }
    }
      else if (r == startmk) {
        recIP = true;
      }
  }
}

void parse() {
  char * strtokIndx;
  strtokIndx = strtok(temp, ' ');
  strcpy(operation, strtokIndx);

  if (operation == 'read') {
    strtokIndx = strtok(NULL, ' ');
    rvalue = atoi(strtokIndx);
    EEPROM.read(rvalue);
 
    }
  else if (operation == 'write') {
    strtokIndx = strtok(NULL, ' ');
    wadd = atoi(strtokIndx);
   
    strtokIndx = strtok(NULL, ' ');
    wval= atoi(strtokIndx);
    EEPROM.write(wadd, wval);
       
  }
 }

void viewparsed(){
     
}

EEPROM.read(rvalue);Read the EEPROM, and then just chuck the value away?

well as I said, I tried assigning it to a global variable (eeread) and then printing that variable via Serial.print(eeread); but nothing was printed to the screen.

if (operation == 'write')

A single character called write?

I tried assigning it to a variable and then printing that variable via Serial.print(eeread);

Can you please post the code that you tried.

How do you know that the EEPROM.read() actually took place ?

 if (operation == 'read')

Is this doing what you think it is ?

UKHeliBob:
Can you please post the code that you tried.

How do you know that the EEPROM.read() actually took place ?

 if (operation == 'read')

Is this doing what you think it is ?

if (operation == 'read') {
    strtokIndx = strtok(NULL, ' ');
    rvalue = atoi(strtokIndx);
    eeread = EEPROM.read(rvalue);
    Serial.print(eeread);

I don't know that the read actually took place. I'm not sure how to check that other than with with the Serial.print() to see what is returned

if (operation == 'read') It seems unlikely that the eeprom read ever takes place, doesn't it?

AWOL:

if (operation == 'write')

A single character called write?

void parse() {
  char * strtokIndx;
  strtokIndx = strtok(temp, ' ');
  strcpy(operation, strtokIndx);

so the way the read command is structured/parsed (or at least how I understand it)
is that you enter the command 'read address' then everything from beginning of line to the first space is passed into the variable. thus leaving me with 'read' in the variable.

thus leaving me with 'read' in the variable.

Whatever you do the variable will not contain 'read' because single quotes can only be used with single characters such as 'r', for instance. Have you tried printing the variable before testing its value ?

As to knowing whether the read actually takes place, how about printing a message just before you do it.

UKHeliBob:
Whatever you do the variable will not contain 'read' because single quotes can only be used with single characters such as 'r', for instance. Have you tried printing the variable before testing its value ?

As to knowing whether the read actually takes place, how about printing a message just before you do it.

ok so I've gone back in an modified the if statements to use either r or w as well as calling a print statement after the variable is set. I think I must have something wrong with my one of my parse statements.

I think I must have something wrong with my one of my parse statements

Please post the larest version of your program.

looking at it with fresh eyes, I think I'm actually trying to parse before I have the string in a variable. I'll play with it more this afternoon. I've got a job interview to prepare for.

#include <EEPROM.h>

const byte chars = 32;
char received[chars];
char temp[chars]; //temp to use for parsing

char operation[chars]= {0};
int rvalue;
int wadd;
int wval;
int eeread;
bool NewInput = false;

void setup() {
  Serial.begin(9600);
  Serial.println("This program reads the value stored in memory addresses(0-1023), or writes a value(0-255) to a memory address");
  Serial.println("Expected format for read is -- read address");
  Serial.println("Expected format for write is -- write address value");
  
 
}

void loop() {
 
  recStEdMarks();
  if (NewInput == true) {
    strcpy(temp, received);
    parse();
    viewparsed();
    NewInput = false;
  }
      
  
}

void recStEdMarks(){
  static bool recIP = false;
  static byte next = 0;
  char startmk = ' ';
  char endmk = ' ';
  char r;

  while (Serial.available() > 0 && NewInput == false){
    r = Serial.read();
    if (recIP == true) {
      if (r != endmk) {
        received[next] = r;
        next++;
        if (next >= chars) {
          next = chars - 1;
        }
      }
      else {
        received[next] = '\0'; //end the string
        recIP = false;
        next = 0;
        NewInput = true;
      }
    }
      else if (r == startmk) {
        recIP = true;
      }
  }
}

void parse() {
  char * strtokIndx;
  strtokIndx = strtok(temp, " ");
  strcpy(operation, strtokIndx);
  
  if (operation == 'r') {
    strtokIndx = strtok(NULL, ' ');
    rvalue = atoi(strtokIndx);
    Serial.print(rvalue);
    eeread = EEPROM.read(rvalue);
   
 
    }
  else if (operation == 'w') {
    strtokIndx = strtok(NULL, ' ');
    wadd = atoi(strtokIndx);
   
    strtokIndx = strtok(NULL, ' ');
    wval= atoi(strtokIndx);
    EEPROM.write(wadd, wval);
       
  }
 }

void viewparsed(){
     
}
char operation[chars]= {0};
...
if (operation == 'w') {

It doesn't seem likely that a single character will equal an array (pointer), does it?
(I'm a little surprised the compiler allowed it - maybe it's just a warning, and it got suppressed)

AWOL:
(I'm a little surprised the compiler allowed it - maybe it's just a warning, and it got suppressed)

It's that >:( >:( >:( -fpermissive >:( >:( >:( again.