Closed SergeySergeevitch closed 1 year ago
What exactly is the issue? I’m guessing you are expecting a longer receive address back?
The 11-bit header goes to the bus, not 29.
You need to use the 29bit flag on the tx flags with the message.
The easiest thing to do is probably set the defaulttxflags on the channel before you call sendmessage
ConnectFlag.CAN_29BIT_ID - i use. There is a suspicion that this flag is not being processed.
The txflags are separate from the connect flags. You need to use both to make 29bit work.
can I have an example?
This does not work:
private void button1_Click(object sender, EventArgs e)
{
MessageFilter PassControlFilter = new MessageFilter()
{
FilterType = Filter.PASS_FILTER,
Mask = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF },
Pattern = new byte[] { 0x1F, 0xFF, 0xFF, 0x01 },
FlowControl = new byte[] { 0x1F, 0xFF, 0xFF, 0x01 },
TxFlags = TxFlag.CAN_29BIT_ID
};
String DllFileName = "C:\\Windows\\SysWOW64\\op20pt32.dll";// string DllFileName = APIFactory.GetAPIinfo().First().Filename;
using (API API = APIFactory.GetAPI(DllFileName))
using (Device Device = API.GetDevice())
using (Channel Channel = Device.GetChannel(Protocol.CAN, Baud.CAN_500000, ConnectFlag.CAN_29BIT_ID))
{
Channel.StartMsgFilter(PassControlFilter);
richTextBox1.AppendText($"Voltage is {Channel.MeasureBatteryVoltage() / 1000}");
Channel.SendMessage(new byte[] { 0x1f, 0xff, 0xff, 0x02, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08});
GetMessageResults Response = Channel.GetMessage();
}
}
Sorry I didn't follow up.
You need to set Channel.DefaultTxFlags |= TxFlag.CAN_29BIT_ID;
In looking at this, it would probably make sense to make that the default flags when a 29bit connection is made. I will look at comitting this soon.
Brian
private void button1_Click(object sender, EventArgs e)
{
MessageFilter PassControlFilter = new MessageFilter()
{
FilterType = Filter.PASS_FILTER,
Mask = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF },
Pattern = new byte[] { 0x1F, 0xFF, 0xFF, 0x01 },
FlowControl = new byte[] { 0x1F, 0xFF, 0xFF, 0x01 },
TxFlags = TxFlag.CAN_29BIT_ID
};
String DllFileName = "C:\\Windows\\SysWOW64\\op20pt32.dll";// string DllFileName = APIFactory.GetAPIinfo().First().Filename;
using (API API = APIFactory.GetAPI(DllFileName))
using (Device Device = API.GetDevice())
using (Channel Channel = Device.GetChannel(Protocol.CAN, Baud.CAN_500000, ConnectFlag.CAN_29BIT_ID))
{
Channel.DefaultTxFlags |= TxFlag.CAN_29BIT_ID;
Channel.StartMsgFilter(PassControlFilter);
richTextBox1.AppendText($"Voltage is {Channel.MeasureBatteryVoltage() / 1000}");
Channel.SendMessage(new byte[] { 0x1f, 0xff, 0xff, 0x02, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08});
GetMessageResults Response = Channel.GetMessage();
}
}
using (Channel Channel = Device.GetChannel(Protocol.CAN, Baud.CAN_500000, ConnectFlag.CAN_29BIT_ID)) { Channel.StartMsgFilter(FlowControlFilter); Channel.SendMessage(new byte[] { 0x1f, 0xff, 0xff, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}); GetMessageResults Response = Channel.GetMessage(); }
receive ID = 701