embedded - Bootloader Flow Control C# -


i'm working program mcu board on rs485. have section of code done access bootloader no problem. problem in code:

int xon_off = comport.readchar(); if (xon_off == send_data) {     int counter = 0;     string line;     system.io.streamreader file = new system.io.streamreader("c:/users/user/desktop/x.hex");     while ((line = file.readline()) != "    ") // reads until end of file     {         write_line: line = file.readline();         if (xon_off == send_data) {             comport.write(line);             //system.threading.thread.sleep(500);             counter++;             xon_off = comport.readbyte(); // should x_off             error_check = comport.readbyte(); // give line complete or error             xon_off = comport.readbyte(); // should x_on         } else if (xon_off == stop_data) {             read_again: xon_off = comport.readbyte();             if (xon_off == send_data) {                 goto write_line;             } else {                 goto read_again;             }         }     } 

my issue flow control (x_on/x_off/eof/etc). way current code is, can send page error, , tool keeps sending nothing, read/compare statements off. can me find out why when sends page error, code thinks it's sending x_on?

note: x_on variable above set 0x11 , x_off var above set 0x13 clarify.

note: once figured out, next step remove goto statements...they're gross know, worked here.

ok can understand, here's better option is: first off, remove goto statements, they're horrindious , should never used. issue of not being able mix chars/hex values, every char when brought in int assigned it's hex value (convert int32 in program). when bootloader sends 0x11, more send char, come software unprintable ascii char, still have 0x11 if use debugger , see it's coming in as. suggestion readbyte, convert int32 in software, , switch statement/state machine want done.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -