J2534_WIN: STYLE CHANGES ONLY.

This commit is contained in:
Jessy Diamond Exum 2017-09-29 01:13:44 -07:00
parent b7cfeeddac
commit b735f17f33
11 changed files with 53 additions and 67 deletions

View File

@ -61,7 +61,7 @@ void J2534_send_msg_checked(unsigned long chanid, unsigned long ProtocolID, unsi
memcpy_s(msg.Data, 4128, Data, DataSize);
unsigned long msgcount = 1;
Assert::AreEqual<long>(STATUS_NOERROR, PassThruWriteMsgs(chanid, &msg, &msgcount, 0), _T("Failed to write message."), pLineInfo);
Assert::AreEqual<unsigned long>(1, msgcount, _T("Wrong message count after tx."), LINE_INFO());
Assert::AreEqual<unsigned long>(1, msgcount, _T("Wrong message count after tx."), pLineInfo);
}
long J2534_send_msg(unsigned long chanid, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags,

View File

@ -107,18 +107,6 @@ long J2534Connection::setBaud(unsigned long baud) {
return STATUS_NOERROR;
}
unsigned long J2534Connection::getBaud() {
return this->BaudRate;
}
unsigned long J2534Connection::getProtocol() {
return this->ProtocolID;
}
unsigned long J2534Connection::getPort() {
return this->port;
}
void J2534Connection::processMessageReceipt(const PASSTHRU_MSG_INTERNAL& msg) {
if (this->loopback) {
synchronized(message_access_lock) {
@ -144,11 +132,3 @@ void J2534Connection::processMessage(const PASSTHRU_MSG_INTERNAL& msg) {
}
}
}
unsigned long J2534Connection::getMinMsgLen() {
return 1;
}
unsigned long J2534Connection::getMaxMsgLen() {
return 4128;
}

View File

@ -2,8 +2,8 @@
#include "panda/panda.h"
#include "J2534_v0404.h"
#include "synchronize.h"
#include "J2534MessageFilter.h"
#include "PandaJ2534Device.h"
#include "J2534MessageFilter.h"
class J2534MessageFilter;
class PandaJ2534Device;
@ -18,7 +18,7 @@ public:
unsigned long Flags,
unsigned long BaudRate
);
~J2534Connection() {};
virtual ~J2534Connection() {};
virtual long PassThruReadMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout);
virtual long PassThruWriteMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout);
virtual long PassThruStartPeriodicMsg(PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval);
@ -38,21 +38,32 @@ public:
long clearMsgFilters();
long setBaud(unsigned long baud);
unsigned long getBaud();
unsigned long getBaud() {
return this->BaudRate;
}
unsigned long getProtocol();
unsigned long getProtocol() {
return this->ProtocolID;
};
virtual bool isProtoCan() {
return FALSE;
}
unsigned long getPort();
unsigned long getPort() {
return this->port;
}
virtual void processMessageReceipt(const PASSTHRU_MSG_INTERNAL& msg);
virtual void processMessage(const PASSTHRU_MSG_INTERNAL& msg);
virtual unsigned long getMinMsgLen();
virtual unsigned long getMaxMsgLen();
virtual unsigned long getMinMsgLen() {
return 1;
}
virtual unsigned long getMaxMsgLen() {
return 4128;
}
bool loopback = FALSE;

View File

@ -40,11 +40,3 @@ long J2534Connection_CAN::PassThruWriteMsgs(PASSTHRU_MSG *pMsg, unsigned long *p
}
return STATUS_NOERROR;
}
unsigned long J2534Connection_CAN::getMinMsgLen() {
return 4;
}
unsigned long J2534Connection_CAN::getMaxMsgLen() {
return 12;
}

View File

@ -16,8 +16,13 @@ public:
virtual long PassThruWriteMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout);
virtual unsigned long getMinMsgLen();
virtual unsigned long getMaxMsgLen();
virtual unsigned long getMinMsgLen() {
return 4;
}
virtual unsigned long getMaxMsgLen() {
return 12;
}
virtual bool isProtoCan() {
return TRUE;

View File

@ -28,7 +28,7 @@ J2534Connection_ISO15765::J2534Connection_ISO15765(
if (BaudRate % 100 || BaudRate < 10000 || BaudRate > 5000000)
throw ERR_INVALID_BAUDRATE;
panda_dev->panda->set_can_speed_cbps(panda::PANDA_CAN1, BaudRate / 100); //J2534Connection_CAN(panda_dev, ProtocolID, Flags, BaudRate) {};
panda_dev->panda->set_can_speed_cbps(panda::PANDA_CAN1, BaudRate / 100);
}
long J2534Connection_ISO15765::PassThruWriteMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout) {
@ -230,14 +230,6 @@ void J2534Connection_ISO15765::processMessage(const PASSTHRU_MSG_INTERNAL& msg)
}
}
unsigned long J2534Connection_ISO15765::getMinMsgLen() {
return 4;
}
unsigned long J2534Connection_ISO15765::getMaxMsgLen() {
return 4099;
}
long J2534Connection_ISO15765::PassThruStartMsgFilter(unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg,
PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID) {

View File

@ -122,9 +122,15 @@ public:
int get_matching_in_fc_filter_id(const PASSTHRU_MSG_INTERNAL & msg, unsigned long flagmask = CAN_29BIT_ID);
virtual void processMessageReceipt(const PASSTHRU_MSG_INTERNAL& msg);
virtual void J2534Connection_ISO15765::processMessage(const PASSTHRU_MSG_INTERNAL& msg);
virtual unsigned long getMinMsgLen();
virtual unsigned long getMaxMsgLen();
virtual void processMessage(const PASSTHRU_MSG_INTERNAL& msg);
virtual unsigned long getMinMsgLen() {
return 4;
}
virtual unsigned long getMaxMsgLen() {
return 4099;
};
virtual bool _is_29bit() {
return (this->Flags & CAN_29BIT_ID) == CAN_29BIT_ID;

View File

@ -7,7 +7,7 @@ J2534MessageFilter::J2534MessageFilter(
PASSTHRU_MSG *pMaskMsg,
PASSTHRU_MSG *pPatternMsg,
PASSTHRU_MSG *pFlowControlMsg
) : filtertype(filtertype), flags(0) {
) : filtertype(filtertype), flags(0), conn(conn) {
switch (filtertype) {
case PASS_FILTER:
case BLOCK_FILTER:

View File

@ -29,6 +29,7 @@ public:
std::string get_flowctrl();
unsigned long flags;
J2534Connection *const conn;
private:
unsigned int filtertype;
std::string maskMsg;

View File

@ -9,19 +9,20 @@ PandaJ2534Device::PandaJ2534Device(std::unique_ptr<panda::Panda> new_panda) {
this->panda->set_can_loopback(FALSE);
this->panda->set_alt_setting(1);
DWORD threadid;
this->can_kill_event = CreateEvent(NULL, TRUE, FALSE, NULL);
this->can_thread_handle = CreateThread(NULL, 0, _can_recv_threadBootstrap, (LPVOID)this, 0, &threadid);
DWORD canListenThreadID;
this->thread_kill_event = CreateEvent(NULL, TRUE, FALSE, NULL);
this->can_thread_handle = CreateThread(NULL, 0, _can_recv_threadBootstrap, (LPVOID)this, 0, &canListenThreadID);
};
PandaJ2534Device::~PandaJ2534Device() {
SetEvent(this->can_kill_event);
SetEvent(this->thread_kill_event);
DWORD res = WaitForSingleObject(this->can_thread_handle, INFINITE);
CloseHandle(this->can_thread_handle);
CloseHandle(this->can_kill_event);
CloseHandle(this->flow_control_thread_handle);
CloseHandle(this->flow_control_wakeup_event);
CloseHandle(this->flow_control_thread_handle);
CloseHandle(this->thread_kill_event);
}
std::shared_ptr<PandaJ2534Device> PandaJ2534Device::openByName(std::string sn) {
@ -67,7 +68,7 @@ DWORD PandaJ2534Device::can_recv_thread() {
DWORD err = TRUE;
while (err) {
std::vector<panda::PANDA_CAN_MSG> msg_recv;
err = this->panda->can_recv_async(this->can_kill_event, msg_recv);
err = this->panda->can_recv_async(this->thread_kill_event, msg_recv);
for (auto msg_in : msg_recv) {
//if (this->_is_29bit() != msg_in.addr_29b) {}
PASSTHRU_MSG_INTERNAL msg_out;
@ -96,14 +97,13 @@ DWORD PandaJ2534Device::can_recv_thread() {
}
}
return STATUS_NOERROR;
return 0;
}
DWORD PandaJ2534Device::_flow_control_write_threadBootstrap(LPVOID This) {
return ((PandaJ2534Device*)This)->flow_control_write_thread();
}
DWORD PandaJ2534Device::flow_control_write_thread()
{
DWORD PandaJ2534Device::flow_control_write_thread() {
return 0;
}

View File

@ -21,15 +21,14 @@ public:
std::vector<std::unique_ptr<J2534Connection>> connections;
private:
HANDLE thread_kill_event;
HANDLE can_thread_handle;
static DWORD WINAPI _can_recv_threadBootstrap(LPVOID This);
DWORD can_recv_thread();
HANDLE can_thread_handle;
HANDLE can_kill_event;
HANDLE flow_control_wakeup_event;
HANDLE flow_control_thread_handle;
static DWORD WINAPI _flow_control_write_threadBootstrap(LPVOID This);
DWORD flow_control_write_thread();
HANDLE flow_control_thread_handle;
HANDLE flow_control_wakeup_event;
};