Commit Graph

66 Commits

Author SHA1 Message Date
Stefan Rueger ea226936b7 Fix isspace() and other isxxx() calls in term.c 2022-07-13 11:19:21 +01:00
Stefan Rueger f8145ae1c4 Echo >>> terminal command line for Windows or non-libreadline 2022-07-12 21:53:37 +01:00
Stefan Rueger b6204b181a Provide echo of terminal command line prompt under Windows 2022-07-12 15:22:52 +01:00
Stefan Rueger 1e8b56751e Add quell command in terminal
Sets the quell_progress global variable that can be, and is, consulted by
programmers.

Setting quell_progress to a positive number also switches off progress
bars. It is currently not possible to switch on progress bars again: that
is enabled in main.c once at the start of AVRDUDE.

That code in main should move to avr.c to enable report_update() to consult
quell_progress directly. Will do at another time when touching main.c and
avr.c. smr
2022-07-12 13:19:09 +01:00
Stefan Rueger d9cb9772d7 Fix verbosity level parsing in term.c 2022-07-12 12:30:29 +01:00
Stefan Rueger 63fb79accb Consolidate more error messages in term.c 2022-07-12 12:24:30 +01:00
Stefan Rueger f871a4dc1e Adapt capitalisation of comments in term.c to existing style 2022-07-12 12:02:43 +01:00
Stefan Rueger 7c766ef9bd Refine type detection in terminal write
The code no longer accepts valid mantissa-only doubles that are integer
rejects, eg, 078 or ULL overflows. These are most likely input errors by
the user: 8 is not an octal digit, they might have typed 17 hex digits,
not 16. It's just too hard to explain that 0xffffFFFFffffFFFFf writes
0x4430000000000000, which is the correct double representation of the
valid 17-digit hex mantissa that strtod() is perfectly happy to accept.
2022-07-12 12:01:14 +01:00
Stefan Rueger 704d253636 Remove comparisons between signed and unsigned integers in term.c 2022-07-12 11:59:42 +01:00
Stefan Rueger 8140c9c90b Consolidate error messages in term.c 2022-07-12 11:58:51 +01:00
Stefan Rueger 56113f6d8a Remove echo of tokenised terminal command 2022-07-12 11:51:04 +01:00
Stefan Rueger c5f522342d Improve terminal help message 2022-07-12 11:50:23 +01:00
Stefan Rueger 92425af0cc Improve terminal dump usage message 2022-07-12 11:47:33 +01:00
Stefan Rueger 602e9bb80c Change size for memory type variable in terminal read 2022-07-12 11:44:20 +01:00
Stefan Rueger 7205bbae80 Enhance terminal read with new mode: read <memory> <addr> 2022-07-12 11:43:45 +01:00
Stefan Rueger aa09bcf900 Ensure terminal writes little endian numbers 2022-07-12 11:42:59 +01:00
Stefan Rueger ddffabe86a Improve terminal write usage message 2022-07-12 11:40:40 +01:00
Stefan Rueger 0b2f38c67d Allow optional comma separators for data items in terminal write 2022-07-12 11:39:52 +01:00
Stefan Rueger 5c4cfa642a Parse terminal writes of string and character constants in C-style 2022-07-12 11:39:02 +01:00
Stefan Rueger 9fe6820236 Add double type for terminal write in anticipation of future avr-libc extension 2022-07-12 11:36:57 +01:00
Stefan Rueger feda75b60a Remove unnecessary bool is_float in terminal write 2022-07-12 11:35:27 +01:00
Stefan Rueger 51355d04fb Remodel logic of the size that integer items occupy in terminal write
Integers can be hexadecimal, decimal or octal. An optional case-insensitive
suffix specifies their size: HH: 8 bit, H/S: 16 bit, L: 32 bit, LL: 64 bit

An optional U suffix makes a number unsigned. Ordinary 0x hex numbers are
always treated as unsigned. +0x or -0x hex numbers are treated as signed
unless they have a U suffix. Unsigned integers cannot be larger than 2^64-1.

If n is an unsigned integer then -n is also a valid unsigned integer as in C.

Signed integers must fall into the [-2^63, 2^63-1] range or a correspondingly
smaller range when a suffix specifies a smaller type. Out of range signed
numbers trigger a warning.

Ordinary 0x hex numbers with n hex digits (counting leading zeros) use
the smallest size of 1, 2, 4 and 8 bytes that can accommodate any n-digit hex
number. If a suffix specifies a size explicitly the corresponding number of
least significant bytes are written. Otherwise, signed and unsigned integers
alike occupy the smallest of 1, 2, 4, or 8 bytes needed to accommodate them
in their respective representation.
2022-07-12 11:32:38 +01:00
Stefan Rueger 62d3eebd56 Fix 64-bit integer terminal write where high bit set
Using strtoll() can only return numbers in the range [-2^63, 2^63-1]. This
means that 0xffffFFFFffffFFFF (2^64-1) will be out of range and is written as
max LL. Actually, every 64-bit number with high-bit set will wrongly be
written as max LL.

This commit uses strtoull() instead to fix this, and checks for unsiged out-
of-range error. strtoull() also has the neat benefit that input with a minus
sign is treated like C unsigned numbers, ie, -u is also a valid unsigned
number if only u is one. In case the input is meant to be treated as signed,
it is therefore still OK to use strtoull() in the first instance only that in
this case a second check against the range of the signed domain is necessary.
2022-07-12 11:19:47 +01:00
Stefan Rueger 9afa56381e Remove unused component is_signed in terminal write 2022-07-12 11:19:05 +01:00
Stefan Rueger ff43e0544d Correct a parse message in terminal write 2022-07-12 11:18:15 +01:00
Stefan Rueger 177834ae7c Ensure enough memory is allocated for buf in terminal write 2022-07-12 11:16:16 +01:00
Stefan Rueger d3ad078577 Ensure terminal write fill mode ... always fills with last data item 2022-07-12 11:15:30 +01:00
Stefan Rueger 39a00bc71e Ensure +0x...f does not strip suffix f in terminal write 2022-07-12 11:14:41 +01:00
Stefan Rueger 360d7c502b Make suffix fully case insensitive (allow Hh, Ll, ...) in terminal write 2022-07-12 11:13:46 +01:00
Stefan Rueger d9450058c8 Cache strlen(argv[i]) in term.c cmd_write() and prevent negative array index 2022-07-12 11:12:20 +01:00
MCUdude 1363c7fe76 Fix buffer overflow issue
when in terminal fill mode
2022-04-09 20:08:44 +02:00
MCUdude 17b67da03e Make sure memory can be filled with a string
... and not just the last character
2022-04-04 09:38:02 +02:00
MCUdude 795dd91575 Code cleanup + formatting 2022-04-01 22:23:55 +02:00
MCUdude 8f100f5df3 Initial support for string write 2022-04-01 21:57:53 +02:00
MCUdude f0f9059ade Tweak nexttok for better string handling
Now a string that starts and ends with a quote (") is combined into a single (argc) argument rather than being split where spaces used to be
2022-04-01 16:52:59 +02:00
Hans 1d0cbc2246
Add progressbar for read and write command (#912) 2022-03-31 22:21:49 +02:00
MCUdude 426ea1fa78 Add missing free()'s 2022-03-18 21:20:58 +01:00
MCUdude 6a5988ad64 Print write info message when in verbose mode 2022-03-18 21:19:36 +01:00
MCUdude dcf771424b Increase buffer size to prevent potential overflow 2022-03-18 19:17:17 +01:00
Jörg Wunsch 0f4b5b223b
Merge pull request #894 from MCUdude/terminal
Improve terminal read functionality
2022-03-03 23:14:37 +01:00
MCUdude d9c52249a9 Restructure "write mode" code 2022-03-03 19:37:42 +01:00
MCUdude c7174d7678 Update description 2022-03-02 20:24:51 +01:00
MCUdude df6e2eea12 Fix terminal write bug
Wouldn't write data properly after an integer >= 2 bytes was written
2022-03-02 20:09:59 +01:00
MCUdude b688b1f601 Add support for read with ... "operator"
This means that you can use ... to read the "rest" of the memory.
$ read eeprom ...   will dump the entire memory
$ read eeorm 0x80 ...   will dump the memory from address 0x80 to the end address
2022-02-28 23:59:30 +01:00
MCUdude d89f695c31 Incread default read size to 256 bytes 2022-02-28 23:59:30 +01:00
Jörg Wunsch 008f95f6ff
Merge pull request #880 from MCUdude/terminal-write
Avrdude terminal write improvements
2022-02-21 21:53:38 +01:00
MCUdude a73567893b Properly handle negative number sizes 2022-02-21 13:43:38 +01:00
MCUdude fa706f0d01 Handle data size warning better
Now it only outputs a warning when the size of the data the user input is actually ambiguous
2022-02-20 23:03:31 +01:00
MCUdude 3532c567ac Add suffix for 8-bit data
use [val]HH or [val]hh to force 8-bit writes to memory
2022-02-20 22:23:15 +01:00
MCUdude bb99a36a14 Formatting
Use enums for write mode, and change datatypes from int/long/char to int32_t/uint8_t where possible
2022-02-20 19:08:30 +01:00