Hi All,
Hopefully I'm posting in the correct area...
I am not familiar at all with perl but I am trying to convert some code over to vb.net (2010).
the bit I am stuck with is the following:
%CTRL_FUNC_CODES = ("REGISTER" => { # CONTROL CODE 0x10"OFFLINE_QUERY" => { "REQUEST" => [0x10, 0x00],"RESPONSE" => [0x10, 0x80] },"SEND_REGISTER_ADDRESS" => {"REQUEST" => [0x10, 0x01],"RESPONSE" => [0x10, 0x81] },"RE_REGISTER" => {"REQUEST" => [0x10, 0x04],"RESPONSE" => "" } },"READ" => { # CONTROL CODE 0x11"QUERY_INVERTER_ID" => {"REQUEST" => [0x11, 0x03],"RESPONSE" => [0x11, 0x83] },"QUERY_NORMAL_INFO" => {"REQUEST" => [0x11, 0x02],"RESPONSE" => [0x11, 0x82] } },"WRITE" => { # CONTROL CODE 0x12 },"EXECUTE" => { # CONTROL CODE 0x13 } );
A bit of code that uses the above data is:
@tmp_packet = (0xAA, 0x55, $our_address, 0x00, 0x00, $destination_address, $ctrl_func_code{"REQUEST"}[0], $ctrl_func_code{"REQUEST"}[1], $data_length);
From my understanding they are something like structures or arrays in VB, would this be right?
If I am reading the code right than this:
$ctrl_func_code{"REQUEST"}[1]
should equal to a two bye array of: "0x10, 0x01" - am I far off?
Could someone please help me convert? I'm a little overwhelmed tying to get my head around it all... :|
Would something like what I have below work? It seems a bit messy, there must be a better way to do it:
Structure CTRL_FUNC_CODESStructure REGISTERStructure OFFLINE_QUERYShared REQUEST() AsByte = {&H10, &H0}Shared RESPONSE() AsByte = {&H10, &H80}EndStructureStructure SEND_REGISTER_ADDRESSShared REQUEST() AsByte = {&H10, &H1}Shared RESPONSE() AsByte = {&H10, &H81}Structure RE_REGISTERShared REQUEST() AsByte = {&H10, &H4}Shared RESPONSE AsString = ""EndStructureEndStructureEndStructureStructure READStructure QUERY_INVERTER_IDShared REQUEST() AsByte = {&H11, &H3}Shared RESPONSE() AsByte = {&H11, &H83}EndStructureStructure QUERY_NORMAL_INFOShared REQUEST() AsByte = {&H11, &H2}Shared RESPONSE() AsByte = {&H11, &H82}EndStructureEndStructureStructure WRITEEndStructureStructure EXECUTEEndStructureEndStructure
Thanks for your help! :)
Mike