SyntaxError: decimal numbers not supported

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: SyntaxError: decimal numbers not supported

Post by pythoncoder » Fri Oct 16, 2015 7:56 am

From a user perspective a lack of floating point arithmetic represents a substantial lack of Python compatibility. It will also result in confusion amongst beginners who may not know how to do arithmetic programming in an integer-only environment.

The lack of a math module pales into insignificance in comparison: it's a consequence of hardware limitations. It should, of course, be clearly stated in the docs.
Peter Hinch
Index to my micropython libraries.

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: SyntaxError: decimal numbers not supported

Post by danicampora » Fri Oct 16, 2015 8:12 am

I agree. I am working now on the docs, hope to push soon. Surprisingly, it doesn't take 15 minutes as everyone thinks...

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: SyntaxError: decimal numbers not supported

Post by pythoncoder » Fri Oct 16, 2015 8:15 am

it doesn't take 15 minutes
I must admit I chuckled at that one ;)
Peter Hinch
Index to my micropython libraries.

nudomarinero
Posts: 4
Joined: Wed Oct 14, 2015 7:34 pm

Re: SyntaxError: decimal numbers not supported

Post by nudomarinero » Fri Oct 16, 2015 11:54 am

I tried to compile the firmware with floating point support but without the math module. At this point I just wanted to check the size of the resulting binary.

I did the following:
  • add #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) to mpconfigport.h
  • add #define MICROPY_PY_MATH (0) to mpconfigport.h
  • add APP_INC += -I../lib/libm to application.mk
  • isolate the function floorf from math.c to its own file
  • add libm/fmodf.c libm/roundf.c libm/floorf.c to APP_LIB_SRC_C in application.mk. I think they are required by some basic built-in operators.
  • comment line 207 in objfloat.c (case MP_BINARY_OP_INPLACE_POWER...) The power function requires powf and this function requires the use of sqrtf which is the function that gave me the asm error.
  • Comment lines 439 to 447 in modbuiltins.c to avoid the use of the powf function. This is just a dirty "trick" to allow the compilation of the firmware.
The size of the final firmware is 189.5 KB

I also gave it a try and uploaded it to the WiPy. It was very easy to do that as it is explained in the documentation. After uploading the binary, (almost) everything worked all right. In this case, trying to use a float number just blocked the WiPy but did not raise the error :) Given that I have no experience with firmware of embedded devices it would have been surprising that it worked.

Later, I could easily restore the original firmware after compiling it with the default options and everything went back to normal.

I will be happy to help with any test needed to implement the floating point arithmetic in the WiPy in the future.

My conclusions: It was actually very easy to do all of this. The WiPy is very robust with respect to firmware changes. I think the documentation is OK and I appreciate and understand the effort of writing it. Thank you!

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: SyntaxError: decimal numbers not supported

Post by danicampora » Fri Oct 16, 2015 12:16 pm

Hello nudomarinero,

Thanks for your efforts, and for your comments! :-). I will try to build a version with float support sometime during the following days.

I am glad to see that you find the WiPy robust regarding software updates. We worked really hard in that direction, and even though the docs are lacking a lot of info, we do have tests for most things running on a dedicated server every night and after every set of commits pushed. This evening a nice update regarding docs and also Blynk support will be posted.

Cheers,
Daniel

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: SyntaxError: decimal numbers not supported

Post by Damien » Sat Oct 17, 2015 11:38 am

When floats are enabled, complex numbers are also enabled by default. You probably don't need these and can disable them by #define MICROPY_PY_BUILTINS_COMPLEX (0)

On pyboard (stmhal port), basic float support costs 7000 bytes of code space (no complex numbers, no math module, but does include powf and sqrtf). Full float support (incl complex numbers, math and cmath modules) costs 23000 bytes of code space.

LarryTru
Posts: 26
Joined: Wed Aug 06, 2014 5:46 am

Re: SyntaxError: decimal numbers not supported

Post by LarryTru » Mon Nov 02, 2015 5:47 am

Hello danicampora,

I'm enjoying beginning to play around with my WiPy. You said you were going to try to build with floating point; any results yet?

Thanks,

Larry

User avatar
rcolistete
Posts: 352
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: SyntaxError: decimal numbers not supported

Post by rcolistete » Thu Dec 31, 2015 3:58 pm

danicampora wrote:Thanks for your efforts, and for your comments! :-). I will try to build a version with float support sometime during the following days.
Please, WiPy will have greater value for me and others interested in collecting, processing and sharing (via WiFi) some sensor data. Using Python, of course 8-)
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

rodrigob
Posts: 15
Joined: Sun Aug 30, 2015 7:41 am

Re: SyntaxError: decimal numbers not supported

Post by rodrigob » Tue Feb 09, 2016 2:03 pm

Any update on this ? Has anyone enabled floating point with success ?

MiPy
Posts: 3
Joined: Sat Sep 12, 2015 3:22 pm

Re: SyntaxError: decimal numbers not supported

Post by MiPy » Sun Mar 06, 2016 9:09 pm

I just updated my Wipy to version 1.6 and wipy version 1.2. Still no support for decimal numbers. Without this feature i can't use my sensor libraries :-(.

Please fix this. Thanks

Post Reply