public SML_Message(SML_Message_Struct msg) { string state = String.Empty; try { state = String.Empty; SML_Octet_String_Struct os = (SML_Octet_String_Struct)Marshal.PtrToStructure(msg.transaction_id, typeof(SML_Octet_String_Struct)); this.transaction_id = new SML_Octet_String(os); Console.WriteLine("Transaction ID Done =>"); this.group_id = Marshal.ReadByte(msg.group_id); Console.WriteLine("Group ID Done => {0:X8}", this.group_id); this.abort_on_error = Marshal.ReadByte(msg.abort_on_error); Console.WriteLine("Abort On Error Done => {0:X8}", this.abort_on_error); this.message_body = (SML_Message_Body_Struct)Marshal.PtrToStructure(msg.message_body, typeof(SML_Message_Body_Struct)); Console.WriteLine("SML_Message_Body Done => "); this.crc = Marshal.ReadInt16(msg.crc); Console.WriteLine("CRC Done => {0:X8}", this.crc); } catch (Exception e) { Exception ex = new Exception("SML_Message creation error: STATE: \n" + state + "\t" + e.Message); throw ex; } }
public SML_Octet_String(SML_Octet_String_Struct os) { this.len = os.len; Console.WriteLine("OCTET:" + this.len); for (int x = 0; x < this.len && x < 64; x++) { IntPtr p = new IntPtr(os.str.ToInt64() + x); this.str += (char)Marshal.ReadByte(p); } }