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

duckyPad configurator should improve argument checking #122

Open
jose1711 opened this issue Mar 26, 2023 · 1 comment
Open

duckyPad configurator should improve argument checking #122

jose1711 opened this issue Mar 26, 2023 · 1 comment

Comments

@jose1711
Copy link
Contributor

configurator (DuckyScript3 version) evaluates the following line of code as valid (Code OK):

DELAY 99999999999999999999999999

yet it reports an error on compilation (int too big to convert) as it cannot fit 16-bits (unsigned short). It would be better if such an error is detected prior Save operation.

@mpieper
Copy link

mpieper commented Aug 24, 2023

In ds_syntax_check.py -> line 65, add a case for the int cast?

You'd have to do due diligence that there are no cases where a uint32 or other type of variable are picked up from the parser.

def check_one_arg(pgm_line):
	split = [x for x in pgm_line.split(' ') if len(x) > 0]
	if len(split) != 2:
		return PARSE_ERROR, "only one argument allowed"
	try:
		value = int(split[1])
                if value >65535:
                    return PARSE_ERROR, "uint16 value exceeded.  limit to range 0-65535"  
	except:
		return PARSE_ERROR, 'invalid value'
	if value < 0:
		return PARSE_ERROR, "value can't be negative"
	return PARSE_OK, ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants