WTB MATH Extension - Willing to pay well for this

Hello, I am not a part of the Kodular community but with Thunkable announcing that they are shutting down the “Classic” block builder middle of next year I have been looking for a place to move my work and Kodular looks like it will be where I go when the time comes. With that being said I am by new means new to block builders.

My app is much different then probably any other app that’s been written for Android with or with out a block based language and I’ve had to come up with a lot of work around’s to make things do what I needed and my app has impressed a lot of programmers that write in C that didn’t think a phone/tablet/Android OS would even be capable of what I’m doing lead alone doing it with a block based programming language. Because of the complexity of what my app does I’m not even going to try explaining what it does as it’s not relative to the extension I need made.

The type of extension I need made should be something very simple but I have not found anyone who wanted to take me up on making this. I can provide an in-depth example of what it needs to do in the form of blocks and a working AIA example, C# function or even a Java example that can be run in Android Studio.

Basically what the extension needs to do is add up HEX values that are in string format.

This would be input to the extension from a pink text block and the extensions output would also end up in a pink text block.
Example: 00FF0ACE0701 = 1DF

The size of the data being input varies from a few hundred characters to as many as 4096 characters. What is being done is the value of each byte(represented as a hex value in string format) are being added up to create a checksum that is the total of all byte values summed.

My current method using only blocks works fine but it’s SUPER slow and blocks the hell out of the main UI thread while the loops running adding up the values. When this same calculation is done in Android Studio it takes 5-10ms to add up each block, when its done in C# or C++ on micro controllers running as slow as 4mhz these blocks still only take 30-40ms to add up. Using blocks only it takes in the neighbor hood of 700-900ms depending on what the vales are that its adding up. Now the time to add up one block wouldn’t even be that bad but I need to sum as many as 512 blocks so this process becomes very time consuming when it could be done in a matter of a few seconds using conventional programming techniques for this.

I’ve spent a long time developing my app(that’s free & with out adds) but I’m at the point where this is the only thing left in my app that’s just nagging at me since I know there are better ways to do this. So…name your price… I mean lets be reasonable here but I’m willing to pay well above what most extensions are going for. For a basic extension that’s a single block and does the bare minimum I’ve outlined I’d gladly pay $25+ USD. For something better written that was able to run in it’s own thread, play nice with list’s and was fast I’d be willing to pay upwards of $50-$75+ USD.

Feel free to send me an email, shoot me a PM or even discuss it right here in this thread.

If you can build this extension and don’t think my offer’s enough…lets talk about it.

1 Like

Welcome.
Kodular has a cryptograhpy component. Could that work for you?

4 Likes

What I’m looking for is similar to the blocks you listed but what I need is actually a lot more simplistic and for it to be able to work with a much larger input strings. Most hash algorithms have a fixed or maximum input size.

I appreciate the idea though. I have been though all the blocks in Kodular and tried out a number of them but there are not any “special” blocks in the IDE that were able to directly do what I am looking for unfortunately.

Maybe that would be a good idea. I think posting an image of your blocks would be enough.

Sure, this should give the general idea of what it’s doing. The actual group of blocks that runs in the clock is far to large for a screen shot. What I removed from the group is mostly just setting up padding on the rest of the block that’s been added up and then it’s saved into a new list with the sum added to the end of it.

I have the clock timer fire at 1ms but it doesn’t actually make any difference. Any timer value from 1 - 500 does the same thing. As soon as it enters the while loop it blocks the UI for close to a full second while the values are added so when it exits the while loop the timer is already due to fire again and it starts the next loop. If I run the entire process in 1 large loop where it loops though every item in the list as it adds them up(to replace needing a clock) it is little faster but no major improvement. The downside to running everything in 1 big loop is once the app is built, on most devices Android will flag an error shortly after it starts the loop for the app not responding and the main UI thread is being blocked. If you ignore the error the loop does complete and all the data was correctly added so its not like there’s an issue there other then being limited to using the same thread the rest of the app runs in.

I did this with a string of 12756 characters and tested it with the companion only.

1 Like

Here is a function in C# that does the same thing but it’s processing the incoming data as bytes rather then a string so its formatted slightly different.

public static UInt16 CalcBlockChecksum(byte Block)
{
UInt16 Sum = 0;
int PayloadLength = (Block[5] << 8) + Block[6];

        for (int i = 4; i < PayloadLength; i++) // skip prio, dest, src, mode
        {
            Sum += Block[i];
        }

        return Sum;
    }

This is a Java function that does what I need to do, this actually does more then the bare min I need to but it should give a better idea how this is actually written. It’s way past the time I should have gone to bed so I did not run this function to make sure it was exactly right so if you see an error in the code I may have just grabbed this out of an older version of the Android project when I was still working on this. I’ll run the function tomorrow and make sure it’s 100% correct, if it does have an error I’ll make sure and update this post.

public boolean CheckBlockSum(String OurChunk)
{
//for block sum, running sum from index 4, to (totallenth/2)-3
int BlockSumVal = 0;

        for (int i=4;i<= ((OurChunk.length()/2)-4); i++)
        {
           // Tempchar = ArrayCheck(OurChunk,i);
               BlockSumVal += Integer.parseInt(ArrayCheck(OurChunk,i),16);
               BlockSumVal = BlockSumVal & 0xFFFF;
        }
      //  Log.d("myTag99","Calcd Block Sum:" + Integer.toHexString(BlockSumVal));

             String ChunkBlocksum = ArrayCheck(OurChunk,(OurChunk.length()/2)-3) + ArrayCheck(OurChunk, 
              (OurChunk.length()/2)-2);
      //  Log.d("myTag99","Read Block Sum:" +  ChunkBlocksum);

            int ChunkasInt = Integer.parseInt(ChunkBlocksum,16);
        if (ChunkasInt == BlockSumVal)
        {
            return true;
        }
        return false;
    }

This is the result with 4096 characters while live testing. The first time i tested it it appeared faster.

I have done almost exactly as you have there and it’s just as slow as running the while test loop. I will dig out the AIA I made of this the last time I was hunting for an extension and a sample file.

The total size of what I need to process is 512 blocks broken down into groups of 4096 characters. When you only do a small amount it may seem fast but to put in perspective how much data this actually is were talking 2,097,152 characters meaning you need to loop 1,048,576 times when processing 2 characters at a time. What may seem quick in your example is going to take a considerable amount of time when its loops that many times.

I misunderstood that you had max 4096 characters to calculate. May i ask what the data is that you are generating?

I think you have to do the calculations in javascript instead of the math blocks.

http://puravidaapps.com/mathhtml.php

2 Likes

I wrote an app for reading and write General Motors Engine control modules. There is a LOT more to this then just the app side of this and I won’t go into detail but it involved creating a boot loader written in Motorola S19 that’s loaded onto the engine computer that allows the flash chip in the computer to be read or written.

Here is an example of what the block sum looks like with the app running. This was only a small section of the computer that was being flashed so it used 48 blocks of 4096 characters each. When I write the entire computer it requires writing up to 512 blocks.

It may be of interest that the tool being used here is one that I designed the hardware for and contributed to the firmware development the tool runs on. The extension I’m looking for is something that’s very simple to do in any program other then a block builder and a lot of that may be because what it’s being used for is not something your going to find hardly any information about on the internet. It’s not that it’s illegal… it’s that in the past anyone that has made it this far into development has commercialized the hardware + software used and now owns a multi million dollar company(not joking). I have open sourced the develop of reading and writing these PCM’s on Githgub, facebook and a number of forums in several formats to offer people a way to work with these computers with out the “licensing” cost commercial companies charge on every Computer thats flashed.

2 Likes

I’m interested, I’ll send you a PM

2 Likes

Based on @Peter’s idea, I made a little JS procedure to calculate the sum. It’s fast and asynchronous; so it shouldn’t lag the UI thread.

(You can simply drag the image into the Creator’s Blocks workspace to add these blocks to your project)

However, as it’s an async procedure, you will have to use a separate event block to capture the result
blocks

8 Likes

Sorry for not getting back to this sooner.

@Vishwas based on the JS you posted I was able to modify it to do exactly what I needed. I’d like to pay you something for taking the time to write the example, but I see your part of the Kodular Staff…I’m happy to make a donation to you if that sort of thing is allowed. It is much…MUCH faster then I would have ever expected was possible with out the use of a custom extension. Thank you so much for sharing the example. The method I was using took approximately 5 minutes to run the calculation for 512 blocks. Using the blocks below it now takes 9 seconds. The speed increase is almost unreal. I’m kind of shocked Kodular hasn’t applied this kind of speed potential to the basic while and for loops. Sure they work the way they are but knowing they could be much faster would blow a lot of peoples minds.

@Peter Because you suggested the idea of using JS that in turn gave Vishwas the idea to write a couple of example blocks I’d like to pay you something since it’s lead to a solution.

For others reading this and that have already messaged me regarding the creation of a custom extension I will contact you by PM but it may take a couple of days as this did generate a lot of interested developers. I would still still be interested in having this made into a stand alone extension and now I have a working example that makes this a whole lot easier to see what needs to be done. Unfortunately a number of parts of my app are not supported or just won’t play nicely with the Kodular IDE at this time. Because I am very close to the next release of my app, for the time being I will have to compile it with Thunkable as it will take a good amount of time to remove the unsupported components from my app and replace them with Kodular equivalents so for now I do still have need of a stand alone extension.

5 Likes

Great that it improved the speed of your calculations. :+1::+1::+1: You don’t have to pay me anything. Like i always say, i am here to learn not to earn. If you want to donate you can take a look at this page.

7 Likes