Sending non-char arrays to Storyboard

Questions and information about Crank Software's Storyboard Engine

Moderator: jamiev

Sending non-char arrays to Storyboard

Postby TonyP » Wed Jan 14, 2015 12:44 pm

Hello,

I am currently having a bit of trouble sending an array of shorts/ints (int16_t/int32_t) to storyboard. Sending Char arrays work just find, both with known size and without.

Here is format with Char array: "1s0 message" .... or with known size: "4u1 arraySize 1s32 arrayMessage"

However, I cannot get the data across when I do the following with shorts/ints: "4s512 arrayOfInts" or "2u512 arrayOfUnsignedShorts"

With the short/int array I just receive 0 on the storyboard side. Everything else is working wonderfully though. I feel like my brain is skipping over something simple here, but I don't see it. Any Ideas on how to pass the short/int array data over? I have 512 points of data to move, so I am hesitant to list 512 individual integers obviously.

Thanks!
TonyP
 
Posts: 21
Joined: Thu Jul 10, 2014 11:37 am

Re: Sending non-char arrays to Storyboard

Postby ChrisK » Fri Jan 23, 2015 3:17 pm

Hi Tony, sorry for the delayed reply.

This is something that should be working. Do you have a sample of what you are trying to do?
ChrisK
 
Posts: 38
Joined: Wed Nov 04, 2009 3:34 pm

Re: Sending non-char arrays to Storyboard

Postby thomas » Mon Jul 20, 2015 2:03 pm

The current Lua API for decoding the format strings into Lua structures does not decode C array structures into a Lua table.

This is primarily due to the format string 'confusion' that occurs with single byte character arrays (ie char name[20]) that could be interpreted as a series of small integers (int8) or it could be interpreted as a character string that is 20 characters long at most. Currently signed single byte arrays are always treated as character strings (the high-runner scenario) while non-single byte arrays only decode the first value and ignore the array component.

For now, you would need to dynamically generate a format string the length of the data you are sending. In Storyboard 4.2 we will be incorporating the arrays as Lua table entries for non-single character values.
thomas
 
Posts: 133
Joined: Mon Nov 02, 2009 4:32 pm
Location: Ottawa

Re: Sending non-char arrays to Storyboard

Postby anba » Wed Dec 21, 2016 7:19 am

Hi,

was there any progress on this topic?
What I can observe from "iogen" it seems not to work yet.
anba
 
Posts: 12
Joined: Fri Nov 18, 2016 2:10 am

Re: Sending non-char arrays to Storyboard

Postby thomas » Wed Dec 21, 2016 8:19 am

Hi,

It is certainly possible to send arrays of values over a Storyboard IO channel and was mentioned in an earlier post, the functionality for receiving an array within a Storyboard application and using it within Lua was introduced in Storyboard 4.2 so that you could send arrays of integers and then receive them and work with them in Lua as a table. The documentation for gre.send_event_data() shows an example of how from Lua you can send an array of integers:

http://www.cranksoftware.com/cranksoftw ... ml#d0e8247

but we could certainly do a better job calling out exactly how an array of values will be received if an array was sent from C. In short, the mapargs.context_event_data field for that data will contain a table instead of a single value:

function MyLuaCallback(mapargs)
local evData = mapargs.context_event_data
local anArrayOfIntegers = evData.myarray

for i=1,#anArrayOfIntegers do
print(string.format("Received [%d] = %d \n", i, anArrayOfIntegers[i]))
end
end

In this case the format string that I would have expected to be sent would be something along the lines of "4s12 myarray" indicating that we have an array of 12 signed 4 byte (ie int32_t) values. This is currently possible to send from C using the Storyboard IO API (<gre/greio.h>) and we have many customers doing so.

However, you are correct the iogen command line doesn't quite have enough logic built into it to allow us to do the same thing. This is being addressed in the next release of Storyboard (due in early 2107) and is expected to look like:
% iogen my_channel my_target my_event 4s12:myarray 1,2,3,4,5,6,7,8,9,10,11,12

However, as I mentioned, the SBIO C and Lua API are already in place ready to handle arrays today, it is just the iogen utility that sits as a loose function atop the SBIO API that doesn't have a command line parser for it. Frankly it was a conscious choice because once you start sending arrays of data, the command line becomes a pretty clumsy place to be doing this. As an alternative, we ship a command line Lua interpreter, sblua, for all of the platforms where we provide iogen and iorcv. If you were to use sblua then you could easily write a standalone Lua script that generates the data you need, including arrays, and you would get the full expressiveness of Lua as a language to work with:

-- send_array.lua --
function SendMyArray()
local fmt = "4s12 myarray"
local data = {}
data.myarray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }
gre.send_event_data("my_event", fmt, data, "my_channel")
end

SendMyArray()
-- send_array.lua --

% sblua send_array.lua

Also to draw out the API a bit more, I've attached a sample project that demonstrates how to send/receive various data scenarios in both C and Lua.

Hope this helps,
Thomas
Attachments
SBIOTransferExample.zip
Storyboard IO Transfer Example
(654.95 KiB) Downloaded 176 times
thomas
 
Posts: 133
Joined: Mon Nov 02, 2009 4:32 pm
Location: Ottawa

Re: Sending non-char arrays to Storyboard

Postby anba » Wed Dec 21, 2016 10:55 am

Hello thomas,

thank you for the clarification. You were a bit too quick, as I just tested it myself from a C++ application and came to the same result.
So sorry for your effort.

Thanks,
Andreas
anba
 
Posts: 12
Joined: Fri Nov 18, 2016 2:10 am


Return to Storyboard Engine

Who is online

Users browsing this forum: No registered users and 3 guests

cron