Thanks again Tom,
I will have to think about this one. I can use pointers in c# but I will need to mark the areas that use them as "unsafe code" to the compiler. I may take this approach, but I am trying to avoid these things if possible and keep the project as "managed' as possible.
--- In
DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Brad,
> Â
> If you fill in all the data into the structure then you will be able to access all the data fields by name. The idea is that both the DSP and the PC have the same complex data structure, the DSP fills in all the structure field by field and then we basically do a word-by-word memory copy from the DSP's structure to the PC's structure and
then the PC can read the fields.
> Â
> If you write code to skip various offsets to grab fields, then if we change the structure definition then your code will all need to change. The beauty of using the C structure is the C compiler on both sides handles all the data layout for you and guarantees they are in sync.
> Â
> The Status structure contains a lot of information from the board, IO bits, floating point positions, ADC readings, etc etc...  The 64 KFLOP IO bits are packed as you described into the BitsState[2] field. The array of two 32-bit words reports the state of all of the 64 IO bits in KFLOP.  BitsState[1] contains I/O bits 32-63 so that word should change if you toggle IO bits 46 or 47. But that is just one example of all the data packed into the structure.
> Â
> If I get some time I'll try to research an example of
how to access raw memory in C#. But I'm suspect it is highly discouraged.
> Â
> I hope this helps.
> TK
> Â
>
> --- On Mon, 6/27/11, bradodarb <bradodarb@...> wrote:
>
>
> From: bradodarb <bradodarb@...>
> Subject: [DynoMotion] Re: MainStatus/GetStatus()
> To:
DynoMotion@yahoogroups.com> Date: Monday, June 27, 2011, 1:35 PM
>
>
> Â
>
>
>
> I think my last question/comment may have brought us back round robin to my original query.
>
> Am I barking up the wrong tree here, or should I expect to see that the same word in the return value should always contain the status
> of a certan value in your struct? Like your in
your example, can I always assume that the first word in the sequence represents the
>
> VersionAndSize field?
>
> If so, I think I can calculate how many bytes each data type of the fields inside of MainStatus and step over the correct number of words for each and parse them accordingly.
>
> Am I over/under simplifying things here? Maybe I should grab the struct over on the interop side and generate a class to
>
> Also::
>
> Playing around with the GetStatus script command further, I cannot really detect a change when I do things like set the bit direction/status.
>
> I am working with the LED (46 & 47). Are these two excluded from the MainStatus?
>
> Thanks,
>
> Brad
>
> --- In
DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> >
> > Hello Tom,
> >
> > I see what you mean. I can format the input as such, my main question is how this would map out to the idividual properties like in your struct.
> >
> > In the past I have worked with devices where once you break the values down to integers, you can take that down to a binary string to get the status of each point of IO.
> >
> >
> > ex -
> > 40 hex = 64 dec which can be represented by:
> >
> > 01000000 in bin
> >
> > I could then say bit 7 is high and all others are low.
> >
> > -Brad
> >
> > --- In
DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi Brad,
> > > ÂÂ
> > > No I don't think that is what you want to do. When I used the term binary I was referring to it as "non-text". There shouldn't be any need to break into bytes or bits. The basic idea is to convert the asci hex into 32 bit integer data and then just store them into the structure's memory.
> > > ÂÂ
> > > The hexidecimal looks correct. The first word is hex:
> > > ÂÂ
> > > 01310068
> > > ÂÂ
> > > This corresponds to the first 32 bit integer word in the structure of
> > > ÂÂ
> > > int VersionAndSize; //bits 16-23 = version, bits 0-15 = size in words
>
> > ÂÂ
> > > so the Hex 68 corresponds to size decimal 104 which indicates total length of the data structure is 104 words (416 bytes).
> > > ÂÂ
> > > In C it is easy to directly access memory directly by casting pointers so that you can store integer variables into other types, but since that can be dangerous C# probably makes that very difficult. I recall someone writing VB solved the problem by writing the data as an array of integers to disk as a binary file, and then reading it back as a structure. But there should be a way to move the data directly.
> > > ÂÂ
> > > Any C# programmers out there?
> > > ÂÂ
> > > Thanks
> > > TK
> > > ÂÂ
> > >
> > >
> > > --- On Mon, 6/27/11, bradodarb <bradodarb@>
wrote:
> > >
> > >
> > > From: bradodarb <bradodarb@>
> > > Subject: [DynoMotion] Re: MainStatus/GetStatus()
> > > To:
DynoMotion@yahoogroups.com> > > Date: Monday, June 27, 2011, 10:34 AM
> > >
> > >
> > > ÂÂ
> > >
> > >
> > >
> > >
> > > I forgot to paste the conversion of the ints to binary strings:
> > >
> > > So the last posted array converts to this.
> > >
> > > ints
> > > Count = 64
> > > [0]: "1"
> > > [1]: "1001001"
> > > [2]: "0"
> > > [3]: "100000100"
> > > [4]:
"1001010101"
> > > [5]: "1001010101"
> > > [6]: "1001001000"
> > > [7]: "0"
> > > [8]: "1001010101"
> > > [9]: "1001010101"
> > > [10]: "1001001000"
> > > [11]: "0"
> > > [12]: "1001010101"
> > > [13]: "1001010101"
> > > [14]: "1001001000"
> > > [15]: "0"
> > > [16]: "1001010101"
> > > [17]: "1001010101"
> > > [18]: "1001001000"
> > > [19]: "0"
> > > [20]: "1001010101"
> > > [21]: "1001010101"
> > > [22]: "1001001000"
> > > [23]: "0"
> > > [24]: "1001010101"
> > > [25]: "1001010101"
> > > [26]: "1001001000"
> > > [27]: "0"
> > > [28]: "1001010101"
> > > [29]: "1001010101"
> > > [30]: "1001001000"
> > > [31]: "0"
> > > [32]:
"1001010101"
> > > [33]: "1001010101"
> > > [34]: "1001001000"
> > > [35]: "0"
> > > [36]: "0"
> > > [37]: "0"
> > > [38]: "0"
> > > [39]: "0"
> > > [40]: "0"
> > > [41]: "0"
> > > [42]: "0"
> > > [43]: "0"
> > > [44]: "0"
> > > [45]: "0"
> > > [46]: "0"
> > > [47]: "0"
> > > [48]: "0"
> > > [49]: "0"
> > > [50]: "0"
> > > [51]: "0"
> > > [52]: "0"
> > > [53]: "0"
> > > [54]: "0"
> > > [55]: "0"
> > > [56]: "0"
> > > [57]: "0"
> > > [58]: "0"
> > > [59]: "0"
> > > [60]: "0"
> > > [61]: "0"
> > > [62]: "0"
> > > [63]: "0"
> > >
> > > --- In
DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > >
> > > > Tom, I encoded the GetStatus return string into hex and split that into a byte array.
> > > >
> > > > With a return value of :
> > > >
> > > > 01310068 FFFFF800 FFFFF800 FFFFF800 FFFFF800 FFFFF800 FFFFF800 FFFFF800 FFFFF800 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> > > >
> > > > I parsed to this :
> > > >
> > > > byteArray
> > > > {byte[64]}
> > > > [0]: 1
> > > > [1]: 49
> > > > [2]: 0
> > > > [3]: 104
> > > > [4]: 255
> > > > [5]:
255
> > > > [6]: 248
> > > > [7]: 0
> > > > [8]: 255
> > > > [9]: 255
> > > > [10]: 248
> > > > [11]: 0
> > > > [12]: 255
> > > > [13]: 255
> > > > [14]: 248
> > > > [15]: 0
> > > > [16]: 255
> > > > [17]: 255
> > > > [18]: 248
> > > > [19]: 0
> > > > [20]: 255
> > > > [21]: 255
> > > > [22]: 248
> > > > [23]: 0
> > > > [24]: 255
> > > > [25]: 255
> > > > [26]: 248
> > > > [27]: 0
> > > > [28]: 255
> > > > [29]: 255
> > > > [30]: 248
> > > > [31]: 0
> > > > [32]: 255
> > > > [33]: 255
> > > > [34]: 248
> > > >
[35]: 0
> > > > [36]: 0
> > > > [37]: 0
> > > > [38]: 0
> > > > [39]: 0
> > > > [40]: 0
> > > > [41]: 0
> > > > [42]: 0
> > > > [43]: 0
> > > > [44]: 0
> > > > [45]: 0
> > > > [46]: 0
> > > > [47]: 0
> > > > [48]: 0
> > > > [49]: 0
> > > > [50]: 0
> > > > [51]: 0
> > > > [52]: 0
> > > > [53]: 0
> > > > [54]: 0
> > > > [55]: 0
> > > > [56]: 0
> > > > [57]: 0
> > > > [58]: 0
> > > > [59]: 0
> > > > [60]: 0
> > > > [61]: 0
> > > > [62]: 0
> > > > [63]: 0
> > > >
> > > >
> > > > Does this look/seem
reasonable?
> > > >
> > > >
> > > > I do not have much experience with binary serialization in c++.
> > > >
> > > > -Brad Murry
> > > >
> > > >
> > > >
> > > > --- In
DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > > >
> > > > >
> > > > >
> > > > > Thanks Tom,
> > > > >
> > > > > It looks like my best bet may be to create that stucture on the MFC interop side and pass it through from there, perhaps as a really long binary string.
> > > > >
> > > > > --- In
DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Hi Brad,
> > > > > > ÂÂÂ
> > > > > > Thers is a C Structure called
> > > > > > ÂÂÂ
> > > > > > MAIN_STATUS
> > > > > > ÂÂÂ
> > > > > > That is declared in PC-DSP.h
> > > > > > ÂÂÂ
> > > > > >  The structure is uploaded as a binary
hexidecimal image of that structure.
> > > > > > ÂÂÂ
> > > > > > I suppose that breaks every rule in the book for C#
> > > > > > ÂÂÂ
> > > > > > There is an example of how the KMotionCNC application does it in
> > > > > > ÂÂÂ
> > > > > >
> > > > > > int CKMotionCNCDlg::GetStatus()
> > > > > > ÂÂÂ
> > > > > > ÂÂÂ
> > > > > > Regards
> > > > > > TK
> > > > > > ÂÂÂ
> > > > > >
> > > > > >
> > > > > > --- On Mon, 6/27/11, bradodarb <bradodarb@> wrote:
> > > > > >
> > > > >
>
> > > > > > From: bradodarb <bradodarb@>
> > > > > > Subject: [DynoMotion] MainStatus/GetStatus()
> > > > > > To:
DynoMotion@yahoogroups.com> > > > > > Date: Monday, June 27, 2011, 8:59 AM
> > > > > >
> > > > > >
> > > > > > ÂÂÂ
> > > > > >
> > > > > >
> > > > > >
> > > > > > From looking around here I see that the struct MainStatus is used to house the bulk update info from the GetStatus script command.
> > > > > >
> > > > > > I have not been able to find where in the sources this object
is being mapped from the return value.
> > > > > >
> > > > > > I wrote a c# routine to split the data on the ' ' char, then parse the 16 words into binary. I have no idea if that is how the original hex string is to be treated, or how to map it from there.
> > > > > >
> > > > > > Any help is appreciated.
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > >
> > > >
> > >
> >
>