Spark functions listed in spark cloud

Hi Dear Spark User,
I observed that one of the function which i registered to Spark cloud using Spark.function is not listed when I use “spark list” from spark client.

To begin with, I just added one of my functions to already existing Application.cpp file.

Do anyone of you know what can the reason be?

Thanks in advance for help.

Without seeing your code, I can only guess that you’re using more than four functions. This is currently the limit, as is described in the docs.

(To include your code, paste it, then select it and press either CRTL+k or the </> button in order to properly format it for the forum)

Hello Moors7,
Thank You for your reply.
Yes, I was using the fifth function which was not listed.
I found that in file spark_utilities.h, USER_FUNC_MAX_COUNT was #define to 4.
I changed it to 10 and fifth function was listed.

BTW, can you please point me to doc which mentions these things, I have gone through several docs, but I never came across 4 function limit.

Thanks in advance.

Currently the application supports the creation of up to 4 different Spark functions.

See under: http://docs.spark.io/firmware/#spark-function

1 Like

@Dave Is there a reason for the limit of 4 functions?

Yup! The way the firmware is written now, each function you register requires a small amount of ram, because the firmware has to keep an array of function pointers in memory. So to conserve ram we capped it at 4 to start. I think the plan is to change that system so it’s a bit more dynamic, and can be more flexible. If you compile locally / edit the firmware, you can change / increase that limit.

Thanks,
David

3 Likes

Sure - now ya tell us after I engineered my multi-function function where I include a 5 character function name, (currently with 13) which is working great btw.
I’m actually liking my multi-function function and the way it works. Have a look… Multi Spark Function

I’m curious, though. With local compile and firmware edit, about how many hard coded functions do you think the Spark could actually run without issues? Could I also use the fram/sd card shield to extend that capability?

Thanks

Hi @MisterNetwork,

I liked your multi-function :slight_smile:

Hmm, how many functions could you support… Essentially we’re talking about building a simple routing table, and lets assume the cloud doesn’t care how many functions you’ve registered. If we’re naive about it, and just make the table bigger… Looking at the function routing structure:

#define USER_FUNC_MAX_COUNT			4
#define USER_FUNC_KEY_LENGTH			12
#define USER_FUNC_ARG_LENGTH			64
I'm pretty sure my byte counts are going to be wrong here
1 bool + 1 int + (1* USER_FUNC_KEY_LENGTH) + (1* USER_FUNC_ARG_LENGTH )

so lets say 1 entry is roughly (1+2+12+64) = 79 bytes of ram. So you could bump it up to 12, and use about 1k of ram, etc. (Please feel free to correct me, I’m sure I got the size of something mixed up in there somewhere… :slight_smile: )

Thanks,
David