John, I think the bigger issue is *why* would you do this ? If you're going to send the data out the serial port anyhow, why not just send the data as its available ?
How about an explanation as to why you would do this, and how you would use it in an application. I will however say this. What you're doing is terribly inefficient on memory usage. On Tue, Nov 25, 2014 at 4:30 PM, John Mladenik <[email protected]> wrote: > I only showed the individual write as an example that also does not work, > it only performs the very first serialWrite and ignores the rest. > Your example does work with various delays between each byte, but this > will work for me. I might still use the: > > b.serialWrite(port, [ > dio6Hi[0] ,dio6Hi[1] ,dio6Hi[2] ,dio6Hi[3] ,dio6Hi[4] ,dio6Hi[5] > ,dio6Hi[6] ,dio6Hi[7] ,dio6Hi[8] ,dio6Hi[9], > dio6Hi[10],dio6Hi[11],dio6Hi[12],dio6Hi[13],dio6Hi[14], > dio6Hi[15],dio6Hi[16],dio6Hi[17],dio6Hi[18],dio6Hi[19] ]); > > command since it writes the bytes consecutive with no delay between each > byte and so is a little more efficient. At 9600 baud it took just over > 20ms to send out the data without the delays between bytes and just under > 200ms with the delays. > > Thanks for the quick response. I learn something every time you post :) > > > On Tuesday, November 25, 2014 3:14:08 PM UTC-8, Jason Kridner wrote: >> >> On Tue, Nov 25, 2014 at 4:23 PM, John Mladenik <[email protected]> >> wrote: >> > Does anyone know an easier way to send a packet of hex data out the >> serial >> > port. Here is what works for me >> > >> > var dio6Hi = [0x7E, 0x00, 0x10, 0x17, 0x01, 0x00, 0x13, 0xA2, 0x00, >> > 0x40, 0xC0, 0xA9, 0x99, 0xFF, 0xFE, 0x02, 0x44, 0x36, 0x05, 0x72 ]; >> > >> > b.serialWrite(port, [ >> > dio6Hi[0] ,dio6Hi[1] ,dio6Hi[2] ,dio6Hi[3] ,dio6Hi[4] >> ,dio6Hi[5] >> > ,dio6Hi[6] ,dio6Hi[7] ,dio6Hi[8] ,dio6Hi[9], >> > >> > dio6Hi[10],dio6Hi[11],dio6Hi[12],dio6Hi[13],dio6Hi[14], >> dio6Hi[15],dio6Hi[16],dio6Hi[17],dio6Hi[18],dio6Hi[19] >> > ]); >> > >> > This will write all of the data in variable dio6Hi out of the UART in >> > order that I want. But I would like to do this or something like it: >> > >> > for (var i = 0; i < dio6Hi.length; i++) { >> > b.serialWrite(port, [dio6Hi[i]] ); >> > } >> > >> > or even this: >> > >> > b.serialWrite(port, [dio6Hi[0]] ); >> > b.serialWrite(port, [dio6Hi[1]] ); >> > b.serialWrite(port, [dio6Hi[2]] ); >> > >> > . >> > . >> > . >> > b.serialWrite(port, [dio6Hi[18]] ); >> > b.serialWrite(port, [dio6Hi[19]] ); >> > >> > Either of these do not work they only send out the first byte in dio[0] >> and >> > then stop. Is there any way with the serialWrite function to index >> the >> > variable with a "for" or other command in order to simplify sending out >> an >> > array of numbers? >> >> I believe your primary issue here is that the calls to b.serialWrite() >> are asynchronous and you aren't waiting for the writes to complete. >> I'm not really sure why you'd want to have individual calls to write >> each byte, but you could try something like: >> >> var i = 0; >> mySerialWrites(); >> function mySerialWrites() { >> if(i < dio6Hi.length) { >> b.serialWrite(port, [dio6Hi[i]], mySerialWrites); >> i++; >> } >> } >> >> I haven't tested this, but I think it might be your issue. Let us know. >> >> > >> > -- >> > For more options, visit http://beagleboard.org/discuss >> > --- >> > You received this message because you are subscribed to the Google >> Groups >> > "BeagleBoard" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an >> > email to [email protected]. >> > For more options, visit https://groups.google.com/d/optout. >> > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
