MCPcopy Create free account
hub / github.com/PowerBroker2/ELMduino / begin

Method begin

src/ELMduino.cpp:23–45  ·  view source on GitHub ↗

bool ELM327::begin(Stream &stream, const bool& debug, const uint16_t& timeout, const char& protocol, const uint16_t& payloadLen, const byte& dataTimeout) Description: ------------ * Constructor for the ELM327 Class; initializes ELM327 Inputs: ------- * Stream &stream - Reference to Serial port connected to ELM327 * bool debug - Specify whether or not to print deb

Source from the content-addressed store, hash-verified

21 * bool - Whether or not the ELM327 was properly initialized
22*/
23bool ELM327::begin( Stream& stream,
24 const bool& debug,
25 const uint16_t& timeout,
26 const char& protocol,
27 const uint16_t& payloadLen,
28 const byte& dataTimeout)
29{
30 elm_port = &stream;
31 PAYLOAD_LEN = payloadLen;
32 debugMode = debug;
33 timeout_ms = timeout;
34 payload = (char *)malloc(PAYLOAD_LEN + 1); // allow for terminating '\0'
35
36 // test if serial port is connected
37 if (!elm_port)
38 return false;
39
40 // try to connect
41 if (!initializeELM(protocol, dataTimeout))
42 return false;
43
44 return true;
45}
46
47ELM327::~ELM327() {
48 if (payload) free(payload);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected