Skip to content

Commit 2f26d09

Browse files
committed
Changed debugging macros in WANDongle and WANDongleSerialPort
Now they use "dbg.h" which is a part of USBHost, thus eliminating the dependency on code from CellularModem.
1 parent aa209e3 commit 2f26d09

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

libraries/USBHost/USBHost3GModule/WANDongle.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define __MODULE__ "WANDongle.cpp"
2626
#endif
2727

28-
#include "core/dbg.h"
28+
#include "dbg.h"
2929
#include <cstdint>
3030
#include "rtos.h"
3131

@@ -47,7 +47,7 @@ bool WANDongle::tryConnect()
4747
{
4848
//FIXME should run on USB thread
4949

50-
DBG("Trying to connect device");
50+
USB_DBG("Trying to connect device");
5151

5252
if (dev_connected) {
5353
return true;
@@ -61,23 +61,23 @@ bool WANDongle::tryConnect()
6161
{
6262
m_pInitializer = NULL; //Will be set in setVidPid callback
6363

64-
DBG("Enumerate");
64+
USB_DBG("Enumerate");
6565
int ret = host->enumerate(dev, this);
6666
if(ret)
6767
{
6868
return false;
6969
}
7070

71-
DBG("Device has VID:%04x PID:%04x", dev->getVid(), dev->getPid());
71+
USB_DBG("Device has VID:%04x PID:%04x", dev->getVid(), dev->getPid());
7272

7373
if(m_pInitializer) //If an initializer has been found
7474
{
75-
DBG("m_pInitializer=%p", m_pInitializer);
76-
DBG("m_pInitializer->getSerialVid()=%04x", m_pInitializer->getSerialVid());
77-
DBG("m_pInitializer->getSerialPid()=%04x", m_pInitializer->getSerialPid());
75+
USB_DBG("m_pInitializer=%p", m_pInitializer);
76+
USB_DBG("m_pInitializer->getSerialVid()=%04x", m_pInitializer->getSerialVid());
77+
USB_DBG("m_pInitializer->getSerialPid()=%04x", m_pInitializer->getSerialPid());
7878
if ((dev->getVid() == m_pInitializer->getSerialVid()) && (dev->getPid() == m_pInitializer->getSerialPid()))
7979
{
80-
DBG("The dongle is in virtual serial mode");
80+
USB_DBG("The dongle is in virtual serial mode");
8181
host->registerDriver(dev, 0, this, &WANDongle::init);
8282
m_serialCount = m_pInitializer->getSerialPortCount();
8383
if( m_serialCount > WANDONGLE_MAX_SERIAL_PORTS )
@@ -86,13 +86,13 @@ bool WANDongle::tryConnect()
8686
}
8787
for(int j = 0; j < m_serialCount; j++)
8888
{
89-
DBG("Connecting serial port #%d", j+1);
90-
DBG("Ep %p", m_pInitializer->getEp(dev, j, false));
91-
DBG("Ep %p", m_pInitializer->getEp(dev, j, true));
89+
USB_DBG("Connecting serial port #%d", j+1);
90+
USB_DBG("Ep %p", m_pInitializer->getEp(dev, j, false));
91+
USB_DBG("Ep %p", m_pInitializer->getEp(dev, j, true));
9292
m_serial[j].connect( dev, m_pInitializer->getEp(dev, j, false), m_pInitializer->getEp(dev, j, true) );
9393
}
9494

95-
DBG("Device connected");
95+
USB_DBG("Device connected");
9696

9797
dev_connected = true;
9898

@@ -101,16 +101,16 @@ bool WANDongle::tryConnect()
101101
}
102102
else if ((dev->getVid() == m_pInitializer->getMSDVid()) && (dev->getPid() == m_pInitializer->getMSDPid()))
103103
{
104-
DBG("Vodafone K3370 dongle detected in MSD mode");
104+
USB_DBG("Vodafone K3370 dongle detected in MSD mode");
105105
//Try to switch
106106
if( m_pInitializer->switchMode(dev) )
107107
{
108-
DBG("Switched OK");
108+
USB_DBG("Switched OK");
109109
return false; //Will be connected on a next iteration
110110
}
111111
else
112112
{
113-
ERR("Could not switch mode");
113+
USB_ERR("Could not switch mode");
114114
return false;
115115
}
116116
}
@@ -171,18 +171,18 @@ void WANDongle::init()
171171
for(unsigned i = 0; i < m_totalInitializers; i++)
172172
{
173173
initializer = m_Initializers[i];
174-
DBG("initializer=%p", initializer);
175-
DBG("initializer->getSerialVid()=%04x", initializer->getSerialVid());
176-
DBG("initializer->getSerialPid()=%04x", initializer->getSerialPid());
174+
USB_DBG("initializer=%p", initializer);
175+
USB_DBG("initializer->getSerialVid()=%04x", initializer->getSerialVid());
176+
USB_DBG("initializer->getSerialPid()=%04x", initializer->getSerialPid());
177177
if ((dev->getVid() == initializer->getSerialVid()) && (dev->getPid() == initializer->getSerialPid()))
178178
{
179-
DBG("The dongle is in virtual serial mode");
179+
USB_DBG("The dongle is in virtual serial mode");
180180
m_pInitializer = initializer;
181181
break;
182182
}
183183
else if ((dev->getVid() == initializer->getMSDVid()) && (dev->getPid() == initializer->getMSDPid()))
184184
{
185-
DBG("Dongle detected in MSD mode");
185+
USB_DBG("Dongle detected in MSD mode");
186186
m_pInitializer = initializer;
187187
break;
188188
}

libraries/USBHost/USBHost3GModule/WANDongleSerialPort.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define __MODULE__ "WANDongleSerialPort.cpp"
2626
#endif
2727

28-
#include "core/dbg.h"
28+
#include "dbg.h"
2929
#include <cstdint>
3030
#include "rtos.h"
3131

@@ -65,31 +65,31 @@ void WANDongleSerialPort::reset()
6565

6666
int WANDongleSerialPort::readPacket()
6767
{
68-
DBG("Read packet on %p", this);
68+
USB_DBG("Read packet on %p", this);
6969
rx_mtx.lock();
7070
if(lock_rx)
7171
{
72-
ERR("Fail");
72+
USB_ERR("Fail");
7373
rx_mtx.unlock();
7474
return -1;
7575
}
7676

7777
if( bulk_in == NULL )
7878
{
79-
WARN("Port is disconnected");
79+
USB_WARN("Port is disconnected");
8080
rx_mtx.unlock();
8181
return -1;
8282
}
8383

8484
lock_rx = true; //Receiving
8585
rx_mtx.unlock();
86-
// DBG("readPacket");
86+
// USB_DBG("readPacket");
8787
//lock_rx.lock();
8888
USB_TYPE res = host->bulkRead(dev, (USBEndpoint *)bulk_in, buf_in, ((USBEndpoint *)bulk_in)->getSize(), false); //Queue transfer
8989
if(res != USB_TYPE_PROCESSING)
9090
{
9191
//lock_rx.unlock();
92-
ERR("host->bulkRead() returned %d", res);
92+
USB_ERR("host->bulkRead() returned %d", res);
9393
Thread::wait(100);
9494
return -1;
9595
}
@@ -101,28 +101,28 @@ int WANDongleSerialPort::writePacket()
101101
tx_mtx.lock();
102102
if(lock_tx)
103103
{
104-
ERR("Fail");
104+
USB_ERR("Fail");
105105
tx_mtx.unlock();
106106
return -1;
107107
}
108108

109109
if( bulk_out == NULL )
110110
{
111-
WARN("Port is disconnected");
111+
USB_WARN("Port is disconnected");
112112
tx_mtx.unlock();
113113
return -1;
114114
}
115115

116116
lock_tx = true; //Transmitting
117117
tx_mtx.unlock();
118-
// DBG("writePacket");
118+
// USB_DBG("writePacket");
119119

120120
//lock_tx.lock();
121121
USB_TYPE res = host->bulkWrite(dev, (USBEndpoint *)bulk_out, buf_out, buf_out_len, false); //Queue transfer
122122
if(res != USB_TYPE_PROCESSING)
123123
{
124124
//lock_tx.unlock();
125-
ERR("host->bulkWrite() returned %d", res);
125+
USB_ERR("host->bulkWrite() returned %d", res);
126126
Thread::wait(100);
127127
return -1;
128128
}
@@ -142,7 +142,7 @@ int WANDongleSerialPort::putc(int c)
142142
}
143143
else
144144
{
145-
ERR("CAN'T WRITE!");
145+
USB_ERR("CAN'T WRITE!");
146146
}
147147
tx_mtx.unlock();
148148
return c;
@@ -162,7 +162,7 @@ int WANDongleSerialPort::getc()
162162
}
163163
else
164164
{
165-
ERR("CAN'T READ!");
165+
USB_ERR("CAN'T READ!");
166166
}
167167
rx_mtx.unlock();
168168
return c;
@@ -305,7 +305,7 @@ void WANDongleSerialPort::rxHandler()
305305
else //Error, try reading again
306306
{
307307
//lock_rx.unlock();
308-
DBG("Trying again");
308+
USB_DBG("Trying again");
309309
readPacket();
310310
}
311311
}

0 commit comments

Comments
 (0)