private void send_message_VSCP(vscp_message msg) { vscp_message_d mes = new vscp_message_d(); mes.priority = (uint)msg.priority; mes.oaddr = (uint)msg.nickname; mes.vclass = (uint)msg.vclass; mes.vtype = (uint)msg.type; mes.hardcoded = msg.hard_mask; mes.data_len = (uint)msg.data.Length; mes.data = new byte[msg.data.Length / 2]; for (int i = 0; i < mes.data.Length; i++) { mes.data[i] = Convert.ToByte(msg.data.Substring(i * 2, 1) + msg.data.Substring(i * 2 + 1, 1), 16); } vscp.SendMessage(mes); }
void send_message_serial(vscp_message msg) { Int32 id = ((msg.priority << 26) | (msg.vclass << 16) | (msg.type << 8) | (msg.nickname)); if (System.Convert.ToBoolean(msg.hard_mask)) { id |= (1 << 25); } string final = "T: " + System.Convert.ToString(id, 16) + ":" + msg.data + ";"; serial.Write(final); }
private void btSend_Click(object sender, EventArgs e) { vscp_message msg = new vscp_message(); sendLog_add(); msg.hard_mask = cbHM.Checked; msg.priority = getPriorityByName(cbPriority.SelectedItem.ToString()); msg.vclass = getClassByName(cbClass.SelectedItem.ToString()); msg.type = getTypeByClassAndName(cbClass.SelectedItem.ToString(), cbType.SelectedItem.ToString()); msg.lenght = System.Convert.ToInt16(cbLen.Text.ToString()); msg.data = data_reformat(tbData.Text, msg.lenght); msg.nickname = System.Convert.ToInt32(tbNickname.Text); send_vscp_msg(msg); }
void send_message_PEAK(vscp_message msg) { UInt32 id = (UInt32)((msg.priority << 26) | (msg.vclass << 16) | (msg.type << 8) | (msg.nickname)); if (System.Convert.ToBoolean(msg.hard_mask)) { id |= (1 << 25); } TPCANMsg CANMsg; TPCANStatus stsResult; // We create a TPCANMsg message structure // CANMsg = new TPCANMsg(); CANMsg.DATA = new byte[8]; // We configurate the Message. The ID (max 0x1FF), // Length of the Data, Message Type (Standard in // this example) and die data // CANMsg.ID = id; CANMsg.LEN = (byte)msg.lenght; CANMsg.MSGTYPE = TPCANMessageType.PCAN_MESSAGE_EXTENDED; // We get so much data as the Len of the message // for (int i = 0; i < CANMsg.LEN; i++) { CANMsg.DATA[i] = Convert.ToByte(msg.data.Substring(i * 2, 1) + msg.data.Substring(i * 2 + 1, 1), 16); } // The message is sent to the configured hardware // stsResult = PCANBasic.Write(m_PcanHandle, ref CANMsg); // The message was successfully sent // if (stsResult != TPCANStatus.PCAN_ERROR_OK) { MessageBox.Show(GetFormatedError(stsResult)); } }
public void send_vscp_msg(vscp_message msg) { switch (cbDevice.SelectedIndex) { case (int)CONNECTON_TYPES.USB: send_message_serial(msg); break; case (int)CONNECTON_TYPES.PEAK: send_message_PEAK(msg); break; case (int)CONNECTON_TYPES.VSCP: send_message_VSCP(msg); break; } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { switch (e.ColumnIndex) { case 8: DataGridViewRow row = send_log.Rows[e.RowIndex]; vscp_message msg = new vscp_message(); msg.priority = getPriorityByName(row.Cells[1].Value.ToString()); msg.hard_mask = Convert.ToBoolean(row.Cells[2].Value); msg.vclass = getClassByName(row.Cells[3].Value.ToString()); msg.type = getTypeByClassAndName(row.Cells[3].Value.ToString(), row.Cells[4].Value.ToString()); msg.nickname = Convert.ToInt16(row.Cells[5].Value); msg.lenght = Convert.ToInt16(row.Cells[6].Value); msg.data = data_reformat(row.Cells[7].Value.ToString(), msg.lenght); send_vscp_msg(msg); break; case 9: send_log.Rows.RemoveAt(e.RowIndex); break; } }
private void send_message_VSCP(vscp_message msg) { vscp_message_d mes = new vscp_message_d(); mes.priority = (uint)msg.priority; mes.oaddr = (uint)msg.nickname; mes.vclass = (uint)msg.vclass; mes.vtype = (uint)msg.type; mes.hardcoded = msg.hard_mask; mes.data_len = (uint)msg.data.Length; mes.data = new byte[msg.data.Length / 2]; for (int i = 0; i < mes.data.Length; i++) mes.data[i] = Convert.ToByte(msg.data.Substring(i * 2, 1) + msg.data.Substring(i * 2 + 1, 1), 16); vscp.SendMessage(mes); }
void send_message_serial(vscp_message msg) { Int32 id = ((msg.priority << 26) | (msg.vclass << 16) | (msg.type << 8) | (msg.nickname)); if (System.Convert.ToBoolean(msg.hard_mask)) id |= (1 << 25); string final = "T: " + System.Convert.ToString(id, 16) + ":" + msg.data + ";"; serial.Write(final); }
void send_message_PEAK(vscp_message msg) { UInt32 id = (UInt32)((msg.priority << 26) | (msg.vclass << 16) | (msg.type << 8) | (msg.nickname)); if (System.Convert.ToBoolean(msg.hard_mask)) id |= (1 << 25); TPCANMsg CANMsg; TPCANStatus stsResult; // We create a TPCANMsg message structure // CANMsg = new TPCANMsg(); CANMsg.DATA = new byte[8]; // We configurate the Message. The ID (max 0x1FF), // Length of the Data, Message Type (Standard in // this example) and die data // CANMsg.ID = id; CANMsg.LEN = (byte) msg.lenght; CANMsg.MSGTYPE = TPCANMessageType.PCAN_MESSAGE_EXTENDED; // We get so much data as the Len of the message // for (int i = 0; i < CANMsg.LEN; i++) CANMsg.DATA[i] = Convert.ToByte(msg.data.Substring(i * 2, 1) + msg.data.Substring(i * 2 + 1, 1), 16); // The message is sent to the configured hardware // stsResult = PCANBasic.Write(m_PcanHandle, ref CANMsg); // The message was successfully sent // if (stsResult != TPCANStatus.PCAN_ERROR_OK) MessageBox.Show(GetFormatedError(stsResult)); }