What is wrong here? Simple serial receive

I need an ultra simple serial byte read without any interrupts or other Arduino baggage.

This works fine on other non-Arduino Mega328 boards but not with Arduino, at least using Serial Monitor.

Hitting 1 and send should turn on my debugger that is just a bunch of Serial.println() statements that monitor various program parameters.

Hitting any other key and send will kill the debug printout.

// includes and other functions not related are removed for this post - they work fine.

volatile bool debug= false;

Setup()  {
      Serial.begin(115200,SERIAL_8N1);
}

void loop()
{
    if (UCSR0A & 0x80)  {  // check for a byte received
        if (UDR0 == '1')  {  // if an ASCII 1
            debug= true;
            Serial.println("Debug ON, hit any key to turn off.");
        }
    else {  // any 8 bit value
            debug= false;
            Serial.println("Debug OFF, hit 1 key to turn off.");
        }
    }

    myloop()  {
    }
}

You have line ending set to None in Serial Monitor, I presume?

  • Does this look okay to you ? :roll_eyes:

Setup()  {

I ignored that, he prob typed it in laboriously to avoid that oh-so-simple "copy for forum" feature in the IDE; surely he compiled it before posting, after all...

Yes, it was laboriously re-typed!

The code is being developed on a secure computer with no internet or external storage devices allowed. USB sticks or any USB storage device is not recognized.

What would you do?

Bear in mind, we have zero crystal balls, so your laboring in a salt mine is unknown to us. We therefore assume lowest common denominator.

No answer yet - what is the line termination setting of your Serial Monitor?

Good point. I have it set to new line.

This is ultimately going to a USB serial chip and expected to be used with HyperTerminal or some other dumb terminal app.

So you send '1' and it is immediately followed by either cr or lf, which negates the debug setting. Capiche?

Not secure. You would not have access to ports.

Yeah, I think this is over. The Op has the answer, and has left the room. 18 topics, only one ever "solved". A pattern emerges.
Muted.

Wrong! USB devices can report what they are. All my development tools have no problems so far, TI MSP, Xilinx, Arduino, Microchip Studio. USB sticks and drives of any type are rejected.

I'm sure someone could hack something together but the average office user does not have that ability.

This is a very large company with deep pockets and major operations in California and Orlando - figure it out. This may be some plugin for Windows they had custom written. I don't know.

Pattern? If I am supposed to close out posts when solved, I can gladly do that.

You don't need to do a CR on a dumb terminal application - or physical terminal if you still have one.

I have used this trick for years. Just not with an Arduino.

Not secure. Show it to your opsec manager.

contradicts...

Tell that to a rubber duck.

Maybe you have a TSR that rejects a few vendor IDs stuck in a port, but "secure" is - no BIOS (or whatever it is now) access, no "boot from external device" and more - making it a terminal that lets you use a network. It is not secure.

What is your problem?

I'm telling you how the engineering computers are set up where I work.

It may not be secure to military standards but it's what they do here? I am not in the media creation group and I would not be surprised if they have tighter restrictions.

What difference does it make to you?

And no, we don't have BIOS or root access either! I also tried using a USB CDROM drive for the early 2000s. It rejected that as well so if they are storing manufacture IDs it must be a long list.

You posted problems. I posted the answer. You either don't get it, or won't acknowledge it. Either is not my problem.

Stick around and help others, you'll quickly pick up on the pattern. Just post for answers and then leave, you are the problem.

I'm telling you how secure computers are secure. Is that a problem in your world?

Not a fan of over classification. You do not have a secure computer if you can tinker with the ports.

What answer. You last brought up the CR issue and I responded how I get around that. just offering more details. I thought this was a knowledge sharing and idea forum. Your hostility is not in line with that. I have always been courteous in my posts.

I'm going to look at more of yours. Perhaps the moderators should as well.

Not a fan of veiled threats, either.

Secure in your mind or application.

And I did acknowledge what I have is probably not the highest level of security.

No computer is 100% secure if you want to go down that road. Companies adjust security as required by the business they are in and executive policies.