Avatar for llakie

llakie

Member since Feb 2018 • Last active Sep 2023
  • 5 conversations
  • 20 comments

Most recent activity

  • in General
    Avatar for llakie

    Now it gets really strange: This works, but why?

    E.getAddressOf(new Int32Array([
                    begin, 0, 0, 0, 0, 0, 0, 0,
                    end, 0, 0, 0,
                    offset,
                    stepping
    ]), true)
    

    Accessing data at index 0, 8, 12 and 13. Any other "configuration" using different 0-spacings does not work. I'm completly lost.

  • in General
    Avatar for llakie

    If I'm not passing the array as a flat data area in the ram, the source code says, that I'm getting an array of JSVar pointers instead. So would it be correct to have an **int params parameter then, since it's actually an array of pointers. How do I retrieve the value of this variable then? Is there some param[0]->get_value()? I did not find anything in the source code.
    But I actually would prefer the flat array option, since this makes working with the values far easier. As said in a comment above: I'm really not that into C at all. I'm just tinkering around with it. Thanks for any of your help.

  • in General
    Avatar for llakie

    Thank you for your reply. Your advice at least solves part of the problem. Now the first variable in the array params[0] is the expected value. But unfortunately not the others (params[1..n]).
    I tried padding the Uint32Array to 32bytes and 64bytes without any further luck. Do you have any other Idea? Does it have something to do with signed or unsigned bytes?

  • in General
    Avatar for llakie

    I also tried to change my C-function signature to

    int find_sequence(unsigned char* buffer, unsigned char* sequence, int sequence_length, int* params) {}
    

    And pass in an Int32Array. This does not work either. What I noticed is, that whenever I'm returning any of the values from params, I get a static value, which stays the same - so something more like a fixed memory address. But I read that accessing a value by ptr[X] automatically dereferences it and lets me access the value as *(ptr + 0) would do.

  • in General
    Avatar for llakie

    Hi Gordon, I just came accross this question here and I've the same problem as user113695. I followed your advice, but I just get "garbage" data delivered in my C-function.
    I'm not the C guy, so I definitly doing something wrong here
    C-Function:

    // int find_sequence(int, int, int, int)
        int find_sequence(unsigned char* buffer, unsigned char* sequence, unsigned int sequence_length, unsigned int* params) {... return params[0]; }
    

    And in the code I'm calling it with

    const result = findNative.find_sequence(
                E.getAddressOf(this.buffer, true),
                E.getAddressOf(sequence, true),
                sequence.length,
                E.getAddressOf(new Uint32Array([
                    this.idx,
                    this.next,
                    offset,
                    stepping
                ]), true)
    );
    

    The first three parameters are working beautifully. No matter if I'm accessing params[0], params[1], params[2] or params[3], they all seem to have random values stored within.

    Could you help out Gordon?
    Thank you very much in advance.

  • in Pico / Wifi / Original Espruino
    Avatar for llakie

    I was just the fact, that I enabled minification, which led to the fact, that no errors were shown at all. Once I turned it off, the error you mentioned appeared :)

  • in Pico / Wifi / Original Espruino
    Avatar for llakie

    Ok, I found the mistake. "continue" is not supported. As I fixed that it worked after turning off any minification of the code. If I minify, it does somehow not work anymore but does not give me any hint why. I was finally able to shave off another 150ms from my computation, which is very good :) Thank you very much Gordon.

  • in Pico / Wifi / Original Espruino
    Avatar for llakie

    Thank you very much. After a bit of experimenting, I'm currently trying to find out, why the following function hangs indefinitly. It's a function which scans a portion (from this.idx to this.next) of an array for a given sequence, starting at an offset using a given stepping width.

    find(sequence, offset, stepping) {
            "jit";
            if (stepping === undefined) {
                stepping = 1;
            }
    
            if (offset === undefined) {
                offset = 0;
            }
    
            for (let i = this.idx + offset; i < this.next - sequence.length; i+=stepping) {
                if (this.buffer[i] !== sequence[0]) {
                    continue;
                }
                
                let idx = i;
    
                for (let j = 1; j < sequence.length; j++) {
                    if (this.buffer[i + j] !== sequence[j]) {
                        idx = -1;
                        // JIT lacks break statement
                        j = sequence.length - 1;
                    }
                }
    
                if (idx !== -1) {
                    return idx;
                }
            }
    
            return -1;
        }
    

    When I run it without jit it works as expected. If the function is jitted, the application hangs without any error. Thank you for your reply

  • in Pico / Wifi / Original Espruino
    Avatar for llakie

    I saw, that only Bluetooth enabled devices are supported. Could you explain why this is? I really would like to use this feature to speed up some computational work on the Microcontroller.
    I'm currently on version 2.17 and I'm using an Espruino WiFi.
    Thank you :)

Actions