Avatar for indianajones

indianajones

Member since Jul 2019 • Last active Sep 2019
  • 5 conversations
  • 50 comments

Most recent activity

  • in Pico / Wifi / Original Espruino
    Avatar for indianajones

    I'm getting a datastream from the audio mixer (MIDI data over TCP), so the data never ends. I suppose I could pre-allocate a 1kb buffer and use it as a FIFO, so long as the consumer code keeps pulling data out.

  • in Pico / Wifi / Original Espruino
    Avatar for indianajones

    After checking out suggestions from @maze1980 and @Robin, I've created my TCP message handler, and it kinda works. I appear to be getting data corruption in the buffer that I copy the incoming data into, and I can't figure out what I'm doing wrong. The handler:

    if(this.tcpBuffer && this.tcpBuffer.byteLength) {
        let leftoverDataLen = this.tcpBuffer.byteLength;
        let tmpBuffer = new Uint8Array(leftoverDataLen + chunk.length);
        tmpBuffer.set(this.tcpBuffer, 0);
        tmpBuffer.set(E.toUint8Array(chunk), leftoverDataLen);
        this.tcpBuffer = tmpBuffer;
    }
    else {
        this.tcpBuffer = E.toUint8Array(chunk);
    }
    

    So I either start off with a brand new copy of the incoming data (converted to Uint8Array), or I append the new data to the end of the current buffer. When done, this.tcpBuffer should contain all of the data that I've not yet processed. Am I doing this correctly / is there a better way to append the data?

    • 34 comments
    • 1,003 views
  • in Pico / Wifi / Original Espruino
    Avatar for indianajones

    @Gordon yes I was completely forgetting some of the rules of scope in javascript.

  • in Pico / Wifi / Original Espruino
    Avatar for indianajones

    @allObjects I agree with @Robin.

    Getting a reliable 'pipe' going may be a challenge...

    Most of the time, my code will be on the receiving end of MIDI data, and most of that will be a burst of NRPN messages after initial connection, and then mostly quiet. So far, so good on that front, but it's still early - plenty of time to screw things up ;-)

  • in Pico / Wifi / Original Espruino
    Avatar for indianajones

    Thanks for the awesome detail @allObjects. My data is MIDI data, so technically 7 bit, although the extended MIDI data is 8-bit. I switched between Uint8 and Uint8Clamped and my data doesn't look any different, so I think I'm safe. However, my 16-bit binary data on USART? Different animal altogether. Good ole' endianness.

  • Avatar for indianajones

    @maze1980 and @Robin, thanks again for your suggestions and links. I had been using Uint8Array, or should I say mis-using it. After reading the links and trying more iterations, I settled on using Uint8ClampedArray, oh and using it correctly also helps. It's working very well now, thanks!

  • Avatar for indianajones

    I have a connection to a device that's sending binary data over a TCP connection, and of course I get the data in chunks, which must be concatenated as new data comes in. Because the data I receive is binary, I have to convert the incoming data using E.toUint8Array, which works great. But when new data comes in, I have to add the new data to the existing Uint8Array, and I'm struggling to find the right way to do this. Anyone have experience with this?

  • Avatar for indianajones

    Final update on this issue. I have it all working now - I can control my Allen & Heath Qu series mixer via MIDI over TCP using the Espruino Wifi. My high-level understanding was accurate, but you guys helped me figure out how to use the dgram and net libraries properly to make it work. Thanks @Gordon for steering me in the right direction, and @Robin and especially @maze1980 for helping me see the errors in my code. Many thanks.

Actions