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

C-Code generation signal range check #8

Closed
xR3b0rn opened this issue Oct 12, 2018 · 1 comment
Closed

C-Code generation signal range check #8

xR3b0rn opened this issue Oct 12, 2018 · 1 comment
Assignees
Labels

Comments

@xR3b0rn
Copy link
Contributor

xR3b0rn commented Oct 12, 2018

The C-Code generator generates wrong code for range check. This code is generated:
if((rval <= -1023.500000) && (rval >= 1023.500000)) {
But the genrator should generate:
if((rval >= -1023.500000) && (rval <= 1023.500000)) {

To fix this, just change
fprintf(o, "\tif((rval <= %f) && (rval >= %f)) {\n", sig->minimum, sig->maximum);
in file 2c.c:239 to:
fprintf(o, "\tif((rval >= %f) && (rval <= %f)) {\n", sig->minimum, sig->maximum);

@xR3b0rn xR3b0rn changed the title C-Code generation C-Code generation signal range check Oct 12, 2018
xR3b0rn referenced this issue Oct 12, 2018
The encode and decode functions have been improved, but there is still a
lot to do to make the code generator better than it is. This has been
highlighted in the many '@todo' comments added.

* Range checks have been added to the encode/decode functions.
* encode/decode functions have a better interface
* This new interface broke the old way of printing variables, so this
will have to be restored somehow.
@howerj
Copy link
Owner

howerj commented Oct 12, 2018

Thanks! That's a quick fix.

howerj added a commit that referenced this issue Oct 12, 2018
Reported by xR3b0rn

	The C-Code generator generates wrong code for range check. This code is generated:
	if((rval <= -1023.500000) && (rval >= 1023.500000)) {
	But the genrator should generate:
	if((rval >= -1023.500000) && (rval <= 1023.500000)) {

	To fix this, just change
	fprintf(o, "\tif((rval <= %f) && (rval >= %f)) {\n", sig->minimum, sig->maximum);
	in file 2c.c:239 to:
	fprintf(o, "\tif((rval >= %f) && (rval <= %f)) {\n", sig->minimum, sig->maximum);

See: #8
@howerj howerj self-assigned this Oct 12, 2018
@howerj howerj added the bug label Oct 12, 2018
@howerj howerj closed this as completed Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants