Skip to content

Commit fdddc50

Browse files
authored
Merge pull request #115 from BCLab-UNM/hotfix-stoi
Diagnostics error displaying "stoi"
2 parents d27e2f1 + 0c0a239 commit fdddc50

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/diagnostics/src/WirelessDiags.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,16 @@ float WirelessDiags::calcBitRate() {
134134

135135
// Convert string to int
136136
string::size_type sz; // alias of size_t
137-
long int rx_bytes = stoi(receive_stat,&sz);
138-
long int tx_bytes = stoi(transmit_stat,&sz);
137+
long int rx_bytes = 0;
138+
long int tx_bytes = 0;
139+
if (!receive_stat.empty())
140+
{
141+
rx_bytes = stoi(receive_stat,&sz);
142+
}
143+
if (!transmit_stat.empty())
144+
{
145+
tx_bytes = stoi(transmit_stat,&sz);
146+
}
139147

140148
// Get the total bytes transmitted and recevied. This is the total bandwidth used.
141149
total_bytes = rx_bytes + tx_bytes;

0 commit comments

Comments
 (0)