I2C is write-only.

This commit is contained in:
Jonathan Naylor 2020-11-15 17:52:29 +00:00
parent 14bb39af63
commit d48939bd90
5 changed files with 3 additions and 62 deletions

View file

@ -105,7 +105,6 @@ public:
virtual unsigned int readSerial(unsigned char* data, unsigned int length) = 0;
virtual bool writeI2C(const unsigned char* data, unsigned int length) = 0;
virtual unsigned int readI2C(unsigned char* data, unsigned int length) = 0;
virtual unsigned char getMode() const = 0;
virtual bool setMode(unsigned char mode) = 0;

View file

@ -107,7 +107,6 @@ public:
virtual unsigned int readSerial(unsigned char* data, unsigned int length) { return 0U; };
virtual bool writeI2C(const unsigned char* data, unsigned int length) { return true; };
virtual unsigned int readI2C(unsigned char* data, unsigned int length) { return 0U; };
virtual unsigned char getMode() const { return MODE_IDLE; };
virtual bool setMode(unsigned char mode) { return true; };

View file

@ -184,9 +184,6 @@ m_txFMData(5000U, "Modem TX FM"),
m_rxAX25Data(1000U, "Modem RX AX.25"),
m_txAX25Data(1000U, "Modem TX AX.25"),
m_rxSerialData(1000U, "Modem RX Serial"),
m_txSerialData(1000U, "Modem TX Serial"),
m_rxI2CData(1000U, "Modem RX I2C"),
m_txI2CData(1000U, "Modem TX I2C"),
m_rxTransparentData(1000U, "Modem RX Transparent"),
m_txTransparentData(1000U, "Modem TX Transparent"),
m_sendTransparentDataFrameType(0U),
@ -875,12 +872,6 @@ void CSerialModem::clock(unsigned int ms)
m_rxSerialData.addData(m_buffer + m_offset, m_length - m_offset);
break;
case MMDVM_I2C_DATA:
if (m_trace)
CUtils::dump(1U, "RX I2C Data", m_buffer, m_length);
m_rxI2CData.addData(m_buffer + m_offset, m_length - m_offset);
break;
default:
LogMessage("Unknown message, type: %02X", m_type);
CUtils::dump("Buffer dump", m_buffer, m_length);
@ -1099,32 +1090,6 @@ void CSerialModem::clock(unsigned int ms)
if (ret != int(len))
LogWarning("Error when writing Transparent data to the MMDVM");
}
if (!m_txSerialData.isEmpty()) {
unsigned char len = 0U;
m_txSerialData.getData(&len, 1U);
m_txSerialData.getData(m_buffer, len);
if (m_trace)
CUtils::dump(1U, "TX Serial Data", m_buffer, len);
int ret = m_serial->write(m_buffer, len);
if (ret != int(len))
LogWarning("Error when writing Serial data to the MMDVM");
}
if (!m_txI2CData.isEmpty()) {
unsigned char len = 0U;
m_txI2CData.getData(&len, 1U);
m_txI2CData.getData(m_buffer, len);
if (m_trace)
CUtils::dump(1U, "TX I2C Data", m_buffer, len);
int ret = m_serial->write(m_buffer, len);
if (ret != int(len))
LogWarning("Error when writing I2C data to the MMDVM");
}
}
void CSerialModem::close()
@ -1290,20 +1255,6 @@ unsigned int CSerialModem::readSerial(unsigned char* data, unsigned int length)
return n;
}
unsigned int CSerialModem::readI2C(unsigned char* data, unsigned int length)
{
assert(data != NULL);
assert(length > 0U);
unsigned int n = 0U;
while (!m_rxI2CData.isEmpty() && n < length) {
m_rxI2CData.getData(data + n, 1U);
n++;
}
return n;
}
bool CSerialModem::hasDStarSpace() const
{
unsigned int space = m_txDStarData.freeSpace() / (DSTAR_FRAME_LENGTH_BYTES + 4U);
@ -1670,9 +1621,7 @@ bool CSerialModem::writeSerial(const unsigned char* data, unsigned int length)
::memcpy(buffer + 3U, data, length);
unsigned char len = length + 3U;
m_txSerialData.addData(&len, 1U);
m_txSerialData.addData(buffer, len);
m_serial->write(buffer, length + 3U);
return true;
}
@ -1691,9 +1640,7 @@ bool CSerialModem::writeI2C(const unsigned char* data, unsigned int length)
::memcpy(buffer + 3U, data, length);
unsigned char len = length + 3U;
m_txI2CData.addData(&len, 1U);
m_txI2CData.addData(buffer, len);
m_serial->write(buffer, length + 3U);
return true;
}

View file

@ -125,7 +125,6 @@ public:
virtual unsigned int readSerial(unsigned char* data, unsigned int length);
virtual bool writeI2C(const unsigned char* data, unsigned int length);
virtual unsigned int readI2C(unsigned char* data, unsigned int length);
virtual unsigned char getMode() const;
virtual bool setMode(unsigned char mode);
@ -208,9 +207,6 @@ private:
CRingBuffer<unsigned char> m_rxAX25Data;
CRingBuffer<unsigned char> m_txAX25Data;
CRingBuffer<unsigned char> m_rxSerialData;
CRingBuffer<unsigned char> m_txSerialData;
CRingBuffer<unsigned char> m_rxI2CData;
CRingBuffer<unsigned char> m_txI2CData;
CRingBuffer<unsigned char> m_rxTransparentData;
CRingBuffer<unsigned char> m_txTransparentData;
unsigned int m_sendTransparentDataFrameType;

View file

@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
const char* VERSION = "20201113";
const char* VERSION = "20201115";
#endif