Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix terminal write edge cases; add one read mode and add quell command #1025

Merged
merged 39 commits into from Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d945005
Cache strlen(argv[i]) in term.c cmd_write() and prevent negative arra…
stefanrueger Jul 12, 2022
360d7c5
Make suffix fully case insensitive (allow Hh, Ll, ...) in terminal write
stefanrueger Jul 12, 2022
39a00bc
Ensure +0x...f does not strip suffix f in terminal write
stefanrueger Jul 12, 2022
d3ad078
Ensure terminal write fill mode ... always fills with last data item
stefanrueger Jul 12, 2022
177834a
Ensure enough memory is allocated for buf in terminal write
stefanrueger Jul 12, 2022
ff43e05
Correct a parse message in terminal write
stefanrueger Jul 12, 2022
9afa563
Remove unused component is_signed in terminal write
stefanrueger Jul 12, 2022
62d3eeb
Fix 64-bit integer terminal write where high bit set
stefanrueger Jul 12, 2022
51355d0
Remodel logic of the size that integer items occupy in terminal write
stefanrueger Jul 12, 2022
feda75b
Remove unnecessary bool is_float in terminal write
stefanrueger Jul 12, 2022
9fe6820
Add double type for terminal write in anticipation of future avr-libc…
stefanrueger Jul 12, 2022
5c4cfa6
Parse terminal writes of string and character constants in C-style
stefanrueger Jul 12, 2022
0b2f38c
Allow optional comma separators for data items in terminal write
stefanrueger Jul 12, 2022
ddffabe
Improve terminal write usage message
stefanrueger Jul 12, 2022
aa09bcf
Ensure terminal writes little endian numbers
stefanrueger Jul 12, 2022
7205bba
Enhance terminal read with new mode: read <memory> <addr>
stefanrueger Jul 12, 2022
602e9bb
Change size for memory type variable in terminal read
stefanrueger Jul 12, 2022
92425af
Improve terminal dump usage message
stefanrueger Jul 12, 2022
c5f5223
Improve terminal help message
stefanrueger Jul 12, 2022
56113f6
Remove echo of tokenised terminal command
stefanrueger Jul 12, 2022
8140c9c
Consolidate error messages in term.c
stefanrueger Jul 12, 2022
704d253
Remove comparisons between signed and unsigned integers in term.c
stefanrueger Jul 12, 2022
7c766ef
Refine type detection in terminal write
stefanrueger Jul 12, 2022
f871a4d
Adapt capitalisation of comments in term.c to existing style
stefanrueger Jul 12, 2022
63fb79a
Consolidate more error messages in term.c
stefanrueger Jul 12, 2022
d9cb977
Fix verbosity level parsing in term.c
stefanrueger Jul 12, 2022
1e8b567
Add quell command in terminal
stefanrueger Jul 12, 2022
b6204b1
Provide echo of terminal command line prompt under Windows
stefanrueger Jul 12, 2022
feb38b8
Merge branch 'avrdudes:main' into terminal
stefanrueger Jul 12, 2022
f8145ae
Echo >>> terminal command line for Windows or non-libreadline
stefanrueger Jul 12, 2022
ea22693
Fix isspace() and other isxxx() calls in term.c
stefanrueger Jul 13, 2022
1efbc64
Add terminal_setup_update_progress() library interface to term.c
stefanrueger Jul 13, 2022
0b3a578
Flush stderr and stdout with all terminal error messages
stefanrueger Jul 13, 2022
b02cce3
Added long double data type for terminal write
stefanrueger Jul 13, 2022
901d49c
Change terminal write usage message to accommodate long double
stefanrueger Jul 13, 2022
5721908
Revert to double/float only in terminal write and clarify usage
stefanrueger Jul 14, 2022
14b2772
Protect terminal dump from vagaries of C libray implementation of isa…
stefanrueger Jul 14, 2022
7ceb163
Echo terminal command line on Apple
stefanrueger Jul 14, 2022
e7e062e
Fix terminal line parsing for strings (to some extent)
stefanrueger Jul 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 2 additions & 78 deletions src/main.c
Expand Up @@ -135,72 +135,6 @@ static void usage(void)
}


static void update_progress_tty (int percent, double etime, char *hdr)
{
static char hashes[51];
static char *header;
static int last = 0;
int i;

setvbuf(stderr, (char*)NULL, _IONBF, 0);

hashes[50] = 0;

memset (hashes, ' ', 50);
for (i=0; i<percent; i+=2) {
hashes[i/2] = '#';
}

if (hdr) {
avrdude_message(MSG_INFO, "\n");
last = 0;
header = hdr;
}

if (last == 0) {
avrdude_message(MSG_INFO, "\r%s | %s | %d%% %0.2fs",
header, hashes, percent, etime);
}

if (percent == 100) {
if (!last) avrdude_message(MSG_INFO, "\n\n");
last = 1;
}

setvbuf(stderr, (char*)NULL, _IOLBF, 0);
}

static void update_progress_no_tty (int percent, double etime, char *hdr)
{
static int done = 0;
static int last = 0;
int cnt = (percent>>1)*2;

setvbuf(stderr, (char*)NULL, _IONBF, 0);

if (hdr) {
avrdude_message(MSG_INFO, "\n%s | ", hdr);
last = 0;
done = 0;
}
else {
while ((cnt > last) && (done == 0)) {
avrdude_message(MSG_INFO, "#");
cnt -= 2;
}
}

if ((percent == 100) && (done == 0)) {
avrdude_message(MSG_INFO, " | 100%% %0.2fs\n\n", etime);
last = 0;
done = 1;
}
else
last = (percent>>1)*2; /* Make last a multiple of 2. */

setvbuf(stderr, (char*)NULL, _IOLBF, 0);
}

static void list_programmers_callback(const char *name, const char *desc,
const char *cfgname, int cfglineno,
void *cookie)
Expand Down Expand Up @@ -759,18 +693,8 @@ int main(int argc, char * argv [])
}
#endif

if (quell_progress == 0) {
if (isatty (STDERR_FILENO))
update_progress = update_progress_tty;
else {
update_progress = update_progress_no_tty;
/* disable all buffering of stderr for compatibility with
software that captures and redirects output to a GUI
i.e. Programmers Notepad */
setvbuf( stderr, NULL, _IONBF, 0 );
setvbuf( stdout, NULL, _IONBF, 0 );
}
}
if (quell_progress == 0)
terminal_setup_update_progress();

/*
* Print out an identifying string so folks can tell what version
Expand Down