Serial issues with a leonardo

I have a leonardo connected to my laptop. Idon't play with serial too much, nottwo way atleast. my sketch didn't work (serialevent never got called) so I tried the serial event example sketch, and that doesn't work w/ my leonardo either. If I just have a Serial.Print, it displays fine on the laptop, but as I said, serial event never seems to be called, e ven in the example.

is this a leonardo issue? or is it me?

ok it seems to be a leonardo issue. I knew I would regret trying new hardware

or is it me?

I'd go with it being just you. Or, more likely, your undisclosed code.

I didn't post the code since I said I was using example code, I figured there was no need.

String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

void setup() {
  // initialize serial:
  Serial.begin(9600);
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
}

void loop() {
  // print the string when a newline arrives:
  if (stringComplete) {
    Serial.println(inputString); 
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}

/*
  SerialEvent occurs whenever a new data comes in the
 hardware serial RX.  This routine is run between each
 time loop() runs, so using delay inside loop can delay
 response.  Multiple bytes of data may be available.
 */
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read(); 
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    } 
  }
}

What is sending the serial data? I see no proof that serialEvent() is not called.

I have it connectedto my laptop via USB cable. If I add somethign like

delay(2000);
Serial.println("Setup compelte");

to the end of setup, I see that msg on the laptop screen no issue, so I know serial com works.

adding a similar chunk of code inside of serialevent never prints to the seral monitor.

I'll repeat my question once more. What is sending the serial data? Yes, I know it is the PC, but a PC is collection of hardware. There is some application on the PC that sends data, not "the PC".

I am sending it using the serial monitor from the arduino IDE

I've confirmed that the serialEvent() method is NOT called on the Leonardo. Not that is is really a big deal, as all that means is that at the end of loop, the amount of data in the serial buffer is determined, and if that is not zero, the function is called.

Adding

if(Serial.available() > 0)
   serialEvent();

to the end of loop() accomplishes the same thing.

I have never used serial event before, always did it sas you described. Untill I was fighting this issue I always thought SerialEvent did some magick behind the scenes (say some kind of "highlevel" inturrupt or something else I don't know about) so that it was actually called outside of normal loop() looping. Is there some inherent benifit to using it, or does it just simplify coding for new folks? I don't plan on using it any more, just adds confusion and strange flow to my cod.e

Is there some inherent benifit to using it

No.

or does it just simplify coding for new folks?

No.

Personally, I think it was a useless addition to the Arduino tool set. A solution looking for a problem, rather than a problem needing a solution.

I don't plan on using it any more, just adds confusion and strange flow to my cod.e

Agreed, especially since you must use global variables to have any data sharing with loop().