Commit Graph

53 Commits

Author SHA1 Message Date
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
MCUdude a9b756e5c7 Add struct initialization list 2022-02-20 12:46:53 +01:00
MCUdude 0e29b43bd0 Add support for 64-bit integers
Also, move everything data related into a struct, to keep tings a little more organized
2022-02-19 23:34:50 +01:00
MCUdude 4b9219edee Add support for suffixes for manually specifying data size
H/h/S/s: 16-bit, L/l: 32-bit, F/f: 32-bit float
2022-02-19 22:48:58 +01:00
MCUdude 62f3b84eee Use union for simpler data representation
It is a bit hacky, but for this purpose it fits surprisingly well
2022-02-19 20:15:52 +01:00
MCUdude 6e7f38e81f Properly handle negative numbers
Now -3.141592 and -32768 are valid numbers that's stored correctly in memory
2022-02-18 09:58:16 +01:00
MCUdude 10e05eed21 Require single quotes when writing characters 2022-02-18 09:58:16 +01:00
MCUdude 551046052e Add support for writing floats 2022-02-18 09:58:16 +01:00
MCUdude 2a92b8cce4 Add support for memory "fill" with arbitrary data too
If you run the following command: $ write eeprom 0x00 0x10 A B C ...

It will write the following data to EEPROM:
|ABCCCCCCCCCCCCCC|
starting from address 0x00
2022-02-18 09:58:16 +01:00
MCUdude c007dc7d24 Add support for writing single characters
Now this is possible: write eeprom 0x00 a b c d e f 0x80 0x90 ! H E L L O
2022-02-18 09:58:16 +01:00
MCUdude 2589b17640 Add support for memory "fill" mode
Syntax: write <memtype> <start addr> <no. byte to write> <byte to write> ...
2022-02-18 09:58:13 +01:00
MCUdude 19e2cae053 Add Curiosity Nano to terminal list 2022-02-14 10:30:21 +01:00
David Fries 112b6edd1c
Set back to programming mode on quit
Otherwise it can't read the fuses and the safe fuse code complains.
2022-01-09 10:27:36 +01:00
Marius Greuel fc54ef5e59 Clean up legacy code 2022-01-07 17:57:02 +01:00