CAN和SV发送数据问题的修复,只发送速度到CAN
This commit is contained in:
@@ -522,16 +522,16 @@ namespace CapMachine.Wpf.CanDrive
|
||||
|
||||
//释放申请的临时缓冲区
|
||||
Marshal.FreeHGlobal(msgPtSend);
|
||||
Console.WriteLine("");
|
||||
//Console.WriteLine("");
|
||||
//发送CAN数据
|
||||
int SendedNum = USB2CAN.CAN_SendMsg(DevHandle, WriteCANIndex, CanMsg, (uint)CanMsg.Length);
|
||||
if (SendedNum >= 0)
|
||||
{
|
||||
Console.WriteLine("Success send frames:{0}", SendedNum);
|
||||
//Console.WriteLine("Success send frames:{0}", SendedNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Send CAN data failed! {0}", SendedNum);
|
||||
//Console.WriteLine("Send CAN data failed! {0}", SendedNum);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -562,20 +562,20 @@ namespace CapMachine.Wpf.CanDrive
|
||||
int CanNum = USB2CAN.CAN_GetMsgWithSize(DevHandle, ReadCANIndex, msgPtRead, CanMsgBuffer.Length);
|
||||
if (CanNum > 0)
|
||||
{
|
||||
Console.WriteLine("Read CanMsgNum = {0}", CanNum);
|
||||
//Console.WriteLine("Read CanMsgNum = {0}", CanNum);
|
||||
for (int i = 0; i < CanNum; i++)
|
||||
{
|
||||
//CanMsgBuffer[i] = (USB2CAN.CAN_MSG)Marshal.PtrToStructure((IntPtr)((UInt32)msgPtRead + i * Marshal.SizeOf(typeof(USB2CAN.CAN_MSG))), typeof(USB2CAN.CAN_MSG)); //有溢出报错
|
||||
CanMsgBuffer[i] = (USB2CAN.CAN_MSG)Marshal.PtrToStructure((IntPtr)(msgPtRead + i * Marshal.SizeOf(typeof(USB2CAN.CAN_MSG))), typeof(USB2CAN.CAN_MSG));
|
||||
|
||||
Console.WriteLine("CanMsg[{0}].ID = 0x{1}", i, CanMsgBuffer[i].ID.ToString("X8"));
|
||||
Console.WriteLine("CanMsg[{0}].TimeStamp = {1}", i, CanMsgBuffer[i].TimeStamp);
|
||||
Console.Write("CanMsg[{0}].Data = ", i);
|
||||
//Console.WriteLine("CanMsg[{0}].ID = 0x{1}", i, CanMsgBuffer[i].ID.ToString("X8"));
|
||||
//Console.WriteLine("CanMsg[{0}].TimeStamp = {1}", i, CanMsgBuffer[i].TimeStamp);
|
||||
//Console.Write("CanMsg[{0}].Data = ", i);
|
||||
for (int j = 0; j < CanMsgBuffer[i].DataLen; j++)
|
||||
{
|
||||
Console.Write("{0} ", CanMsgBuffer[i].Data[j].ToString("X2"));
|
||||
//Console.Write("{0} ", CanMsgBuffer[i].Data[j].ToString("X2"));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
//Console.WriteLine("");
|
||||
|
||||
//报文给高速记录的服务
|
||||
HighSpeedDataService.AppendOrUpdateMsg(new Models.HighSpeed.CommMsg()
|
||||
@@ -589,13 +589,13 @@ namespace CapMachine.Wpf.CanDrive
|
||||
}
|
||||
else if (CanNum == 0)
|
||||
{
|
||||
Console.WriteLine("No CAN data!");
|
||||
//Console.WriteLine("No CAN data!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Get CAN data error!");
|
||||
//Console.WriteLine("Get CAN data error!");
|
||||
}
|
||||
Console.WriteLine("");
|
||||
//Console.WriteLine("");
|
||||
|
||||
//将CAN消息数据填充到信号里面,用DBC解析数据
|
||||
CAN_DBCParser.DBC_SyncCANMsgToValue(DBCHandle, msgPtRead, CanNum);
|
||||
@@ -608,7 +608,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
//{
|
||||
CAN_DBCParser.DBC_GetSignalValueStr(DBCHandle, new StringBuilder(item.MsgName), new StringBuilder(item.SignalName), ValueSb);
|
||||
item.SignalRtValueSb = ValueSb;
|
||||
Console.Write(ValueSb.ToString());
|
||||
//Console.Write(ValueSb.ToString());
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user