--- /dev/null
+OBD-II Source Plugin
+
+The OBD-II Source plugin uses ELM compatible scantools to get vehicle information.
+It is known to work with a number of commercial scantools including:
+
+OBDLink MX
+OBDLink S
+OBDPro USB
+
+To use the OBD-II Source plugin, add the following config to your /etc/ambd/config:
+
+
+"sources" : [
+ {
+ "name" : "OBD2Source",
+ "path" : "/usr/lib/automotive-message-broker/obd2sourceplugin.so",
+ "device" : "/dev/ttyUSB0",
+ "baud" : "9600",
+ "bluetoothAdapter" : ""
+ }
+ ]
+
+Configuration Key Definitions:
+"name"
+name of plugin. This key is not used by the plugin at this moment.
+
+"path"
+path to plugin on the filesystem.
+
+"device"
+OBD-II Scantool device. This is usually a serial device. For bluetooth devices, use the bluetooth address for example: "00:00:11:aa:bb:cc".
+
+"baud"
+baud rate for OBD-II scantool. OBDLink *-style scantool usually default to 115200. Refer to your scantool docutmentation for the correct baud rate. Note also that some bluetooth scantools, like the OBDLink MX have automatic baud selection and will ignore this value.
+
+"bluetoothAdapter"
+Hardware address of the bluetooth adapter to use. If value is blank (ie "bluetoothAdapter" : ""), the system default adapter will be used. The bluetoothAdapter key is only used if the "device" key is also set to a bluetooth device address.
+
+
+Performance
+
+Performance will vary with the scantool. Here are the current performance numbers per tested scantool:
+
+scantool - properties/second = (pids/s) - baud
+
+OBDLink MX - 80 pids/s - N/A
+OBDLink S - 100 pids/s - 115200
+OBDPro USB - 43 pids/s - 9600
+
+
+
{
clientConnected = false;
m_re = re;
-
- m_supportedProperties.push_back(VehicleProperty::EngineSpeed); //0D
- m_supportedProperties.push_back(VehicleProperty::VehicleSpeed); //0C
- m_supportedProperties.push_back(VehicleProperty::EngineCoolantTemperature); //05
- m_supportedProperties.push_back(VehicleProperty::MassAirFlow); //10
- m_supportedProperties.push_back(VehicleProperty::VIN);
- m_supportedProperties.push_back(VehicleProperty::WMI);
- m_supportedProperties.push_back(VehicleProperty::EngineOilTemperature);
- m_supportedProperties.push_back(VehicleProperty::InteriorTemperature);
- m_supportedProperties.push_back(VehicleProperty::BatteryVoltage);
+
+ Obd2Amb obd2amb;
+
+ for(auto itr = obd2amb.propertyPidMap.begin(); itr != obd2amb.propertyPidMap.end(); itr++)
+ {
+ m_supportedProperties.push_back((*itr).first);
+ }
+
re->setSupported(supported(), this);
/*if (openPort(std::string("/dev/pts/7"),115200))
{
}
void OBD2Source::subscribeToPropertyChanges(VehicleProperty::Property property)
{
- //printf("Subscribed to property: %s\n",property.c_str());
+ /*//printf("Subscribed to property: %s\n",property.c_str());
if (property == VehicleProperty::EngineSpeed)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "010C\r";
+ requ->req = "010C1\r";
g_async_queue_push(subscriptionAddQueue,requ);
}
else if (property == VehicleProperty::MassAirFlow)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "0110\r";
+ requ->req = "01101\r";
g_async_queue_push(subscriptionAddQueue,requ);
}
else if (property == VehicleProperty::VehicleSpeed)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "010D\r";
+ requ->req = "010D1\r";
g_async_queue_push(subscriptionAddQueue,requ);
}
else if (property == VehicleProperty::EngineCoolantTemperature)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "0105\r";
+ requ->req = "01051\r";
g_async_queue_push(subscriptionAddQueue,requ);
}
else if (property == VehicleProperty::VIN)
else if (property == VehicleProperty::EngineOilTemperature)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "015C\r";
+ requ->req = "015C1\r";
g_async_queue_push(subscriptionAddQueue,requ);
}
else if (property == VehicleProperty::InteriorTemperature)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "0146\r";
+ requ->req = "01461\r";
g_async_queue_push(subscriptionAddQueue,requ);
}
else if (property == VehicleProperty::BatteryVoltage)
m_supportedProperties.push_back(VehicleProperty::EngineOilTemperature);
m_supportedProperties.push_back(VehicleProperty::InteriorTemperature);
m_supportedProperties.push_back(VehicleProperty::BatteryVoltage);*/
- else
+ /*else
{
//printf("Unsupported property: %s\n",property.c_str());
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Unsupported property requested:" << property << "\n";
+ }*/
+
+ if (property == VehicleProperty::VIN)
+ {
+ DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "VIN subscription requested... but there's no point!\n";
+ }
+ else if (property == VehicleProperty::WMI)
+ {
+ DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "WMI subscription requested... but there's no point!\n";
+ }
+ else
+ {
+ if(!ListPlusPlus<VehicleProperty::Property>(&m_supportedProperties).contains(property))
+ {
+ DebugOut(0)<<"obd plugin does not support: "<<property<<endl;
+ return;
+ }
+
+ Obd2Amb obd2amb;
+ ObdRequest *requ = new ObdRequest();
+ requ->req = obd2amb.propertyPidMap[property];
+ g_async_queue_push(subscriptionAddQueue,requ);
}
}
void OBD2Source::unsubscribeToPropertyChanges(VehicleProperty::Property property)
{
//
- if (property == VehicleProperty::EngineSpeed)
+ /*if (property == VehicleProperty::EngineSpeed)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "010C\r";
+ requ->req = "010C1\r";
g_async_queue_push(subscriptionRemoveQueue,requ);
}
else if (property == VehicleProperty::MassAirFlow)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "0110\r";
+ requ->req = "01101\r";
g_async_queue_push(subscriptionRemoveQueue,requ);
}
else if (property == VehicleProperty::VehicleSpeed)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "010D\r";
+ requ->req = "010D1\r";
g_async_queue_push(subscriptionRemoveQueue,requ);
}
else if (property == VehicleProperty::EngineCoolantTemperature)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "0105\r";
+ requ->req = "01051\r";
g_async_queue_push(subscriptionRemoveQueue,requ);
}
else if (property == VehicleProperty::VIN)
else if (property == VehicleProperty::EngineOilTemperature)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "015C\r";
+ requ->req = "015C1\r";
g_async_queue_push(subscriptionRemoveQueue,requ);
}
else if (property == VehicleProperty::InteriorTemperature)
{
ObdRequest *requ = new ObdRequest();
- requ->req = "0146\r";
+ requ->req = "01461\r";
g_async_queue_push(subscriptionRemoveQueue,requ);
}
else if (property == VehicleProperty::BatteryVoltage)
requ->req = "ATRV\r";
g_async_queue_push(subscriptionRemoveQueue,requ);
}
+ */
+
+ if(!ListPlusPlus<VehicleProperty::Property>(&m_supportedProperties).contains(property))
+ {
+ DebugOut(0)<<"obd plugin does not support: "<<property<<endl;
+ return;
+ }
+
+ Obd2Amb obd2amb;
+ ObdRequest *requ = new ObdRequest();
+ requ->req = obd2amb.propertyPidMap[property];
+ g_async_queue_push(subscriptionRemoveQueue,requ);
}
{
propertyReplyMap[reply->property] = reply;
VehicleProperty::Property property = reply->property;
+
//TODO: There is a much better way to do this, but for now it's hardcoded.
- if (property == VehicleProperty::EngineSpeed)
+ /*if (property == VehicleProperty::EngineSpeed)
{
ObdRequest *requ = new ObdRequest();
requ->req = "010C\r";
requ->req = "ATRV\r";
g_async_queue_push(singleShotQueue,requ);
}
+ */
+
+ ///Here's a better way:
+
+ if(!ListPlusPlus<VehicleProperty::Property>(&m_supportedProperties).contains(property))
+ {
+ DebugOut(0)<<"obd plugin does not support: "<<property<<endl;
+ return;
+ }
+
+ Obd2Amb obd2amb;
+ ObdRequest *requ = new ObdRequest();
+ requ->req = obd2amb.propertyPidMap[property];
+ g_async_queue_push(singleShotQueue,requ);
}
void OBD2Source::setProperty(VehicleProperty::Property , AbstractPropertyType * )