Hi community
I’m having an issue I still didn’t find anyone complaining about.
I’ve created a route in the Hologram Cloud to other cloud. This other cloud will reply with a string back to the Hologram Cloud to the port 4444.
This message received on the port 4444 should be read on the hologram dash.
The issue:
Sometimes, I get a deadlock on the hologram cloud handle and sometimes I don’t receive anything from the port 4444.
For the sake of simplicity, I’ve removed all the classes from my code, and left only a single file to reproduce this issue.
To test this, you will need to have a route in Hologram Cloud to another Cloud (Azure, for example), and have this other cloud to reply something back back to Hologram Cloud to port 4444.
I’ve created this sample, where every 25 seconds, it will send a message to the cloud.
It takes sometime to start, since I’m waiting 20seconds to be connected to the network.
(I see my messages on the Hologram Cloud) and the OK message on my hologram cloud.
Here is my code:
static const int mSizeInBound = 4096;
char mBufferInbound[mSizeInBound];
volatile bool mNewCloudMsg;
uint32_t mAliveTimeCheck;
const int mAliveTimeoutMs = 1 * 1000; // 1 second
void inbound(int length)
{
mBufferInbound[length] = 0;
mNewCloudMsg = true;
}
void notify(cloud_event e)
{
switch(e)
{
case CLOUD_EVENT_DISCONNECTED:
HologramCloud.listen(4444);
break;
}
}
void send(const String& msg, const String& topic)
{
String tmp = "topic: " + topic;
tmp += " msg: ";
tmp += msg;
Serial.print("Sending to cloud = ");
Serial.println(tmp);
HologramCloud.connect();
HologramCloud.print(msg);
HologramCloud.attachTopic(topic);
if(HologramCloud.sendMessage() == false)
{
Serial.println("Msg was not sent to Cloud :(");
}
else
{
Serial.println("Msg was sent to Cloud :)");
}
}
void setup()
{
Serial.begin(9600);
HologramCloud.clear();
HologramCloud.disconnect();
HologramCloud.resetSystem();
HologramCloud.powerDown();
delay(5000);
HologramCloud.attachHandlerInbound(inbound, mBufferInbound, mSizeInBound - 1);
HologramCloud.attachHandlerNotify(notify);
HologramCloud.begin();
HologramCloud.resetSystem();
delay(20000);
HologramCloud.listen(4444);
}
void loop()
{
const uint32_t ms = millis();
if (mAliveTimeCheck < ms)
{
mAliveTimeCheck = ms + mAliveTimeoutMs;
Serial.print(".");
static int counter = 0;
Serial.print(counter);
Serial.print(" ");
Serial.print(millis());
Serial.print(" ");
counter++;
Serial.println(HologramCloud.getNetworkOperator());
static int count = 0;
count++;
if(count % 25 == 0)
{
send("{\"test\":\"987654321\"}", "TESTTOPIC");
}
}
HologramCloud.pollEvents();
if(true == mNewCloudMsg)
{
mNewCloudMsg = false;
Serial.println("Received from cloud:");
Serial.println(mBufferInbound);
}
HologramCloud.powerUp();
}
And here is the output:
.0 25657 vodafone P
.1 26675 vodafone P
.2 27682 vodafone P
.3 28689 vodafone P
.4 29699 vodafone P
.5 30706 vodafone P
.6 31712 vodafone P
.7 32720 vodafone P
.8 33725 vodafone P
.9 34732 vodafone P
.10 35739 vodafone P
.11 36754 vodafone P
.12 37761 vodafone P
.13 38764 vodafone P
.14 39769 vodafone P
.15 40771 vodafone P
.16 41776 vodafone P
.17 42780 vodafone P
.18 43782 vodafone P
.19 44788 vodafone P
.20 45789 vodafone P
.21 46793 vodafone P
.22 47803 vodafone P
.23 48816 vodafone P
.24 49835 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.25 53128 vodafone P
.26 54132 vodafone P
.27 55134 vodafone P
.28 56137 vodafone P
Received from cloud:
True
.29 57147 vodafone P
.30 58151 vodafone P
.31 59152 vodafone P
.32 60156 vodafone P
.33 61163 vodafone P
.34 62166 vodafone P
.35 63178 vodafone P
.36 64197 vodafone P
.37 65200 vodafone P
.38 66209 vodafone P
.39 67214 vodafone P
.40 68215 vodafone P
.41 69216 vodafone P
.42 70218 vodafone P
.43 71225 vodafone P
.44 72227 vodafone P
.45 73229 vodafone P
.46 74232 vodafone P
.47 75248 vodafone P
.48 76268 vodafone P
.49 77282 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.50 79489 vodafone P
.51 80493 vodafone P
.52 81500 vodafone P
.53 82504 vodafone P
Received from cloud:
True
.54 83815 vodafone P
.55 84819 vodafone P
.56 85819 vodafone P
.57 86824 vodafone P
.58 87827 vodafone P
.59 88832 vodafone P
.60 89835 vodafone P
.61 90836 vodafone P
.62 91842 vodafone P
.63 92844 vodafone P
.64 93846 vodafone P
.65 94849 vodafone P
.66 95872 vodafone P
.67 96887 vodafone P
.68 97902 vodafone P
.69 98911 vodafone P
.70 99925 vodafone P
.71 100939 vodafone P
.72 101956 vodafone P
.73 102969 vodafone P
.74 103984 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.75 106939 vodafone P
.76 107944 vodafone P
.77 108947 vodafone P
.78 109972 vodafone P
Received from cloud:
True
.79 110989 vodafone P
.80 111993 vodafone P
.81 112998 vodafone P
.82 114002 vodafone P
.83 115009 vodafone P
.84 116811 vodafone P
.85 117825 vodafone P
.86 118826 vodafone P
.87 119827 vodafone P
.88 120830 vodafone P
.89 121834 vodafone P
.90 122837 vodafone P
.91 123839 vodafone P
.92 124843 vodafone P
.93 125846 vodafone P
.94 126851 vodafone P
.95 127869 vodafone P
.96 128884 vodafone P
.97 129898 vodafone P
.98 130908 vodafone P
.99 131923 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.100 134310 vodafone P
.101 135332 vodafone P
.102 136335 vodafone P
Received from cloud:
True
.103 137396 vodafone P
.104 138406 vodafone P
.105 139412 vodafone P
.106 140421 vodafone P
.107 141440 vodafone P
.108 142441 vodafone P
.109 143462 vodafone P
.110 144464 vodafone P
.111 145467 vodafone P
.112 146488 vodafone P
.113 147493 vodafone P
.114 148496 vodafone P
.115 149500 vodafone P
.116 150502 vodafone P
.117 151507 vodafone P
.118 152521 vodafone P
.119 153534 vodafone P
.120 154555 vodafone P
.121 155564 vodafone P
.122 156575 vodafone P
.123 157587 vodafone P
.124 158604 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.125 161040 vodafone P
.126 162047 vodafone P
.127 163048 vodafone P
.128 164815 vodafone P
Received from cloud:
True
.129 165822 vodafone P
.130 167481 Not available
.131 168497 vodafone P
.132 169504 vodafone P
.133 170507 vodafone P
.134 171509 vodafone P
.135 172530 vodafone P
.136 173532 vodafone P
.137 174540 vodafone P
.138 175541 vodafone P
.139 176544 vodafone P
.140 177546 vodafone P
.141 178555 vodafone P
.142 179568 vodafone P
.143 180584 vodafone P
.144 181598 vodafone P
.145 182613 vodafone P
.146 183622 vodafone P
.147 184637 vodafone P
.148 185646 vodafone P
.149 186660 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.150 189021 vodafone P
.151 190026 vodafone P
.152 192016 vodafone P
Received from cloud:
.153 193022 vodafone P
.154 194023 vodafone P
.155 195033 vodafone P
.156 196045 vodafone P
.157 197826 vodafone P
.158 198831 vodafone P
.159 199834 vodafone P
.160 200838 vodafone P
.161 201841 vodafone P
.162 202842 vodafone P
.163 203843 vodafone P
.164 204849 vodafone P
.165 205850 vodafone P
.166 206852 vodafone P
.167 207859 vodafone P
.168 208871 vodafone P
.169 209881 vodafone P
.170 210895 vodafone P
.171 211908 vodafone P
.172 212919 vodafone P
.173 213933 vodafone P
.174 214955 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.175 217324 vodafone P
.176 218328 vodafone P
.177 219334 vodafone P
.178 220458 vodafone P
Received from cloud:
True
.179 221461 vodafone P
.180 222467 vodafone P
.181 224097 vodafone P
.182 225102 vodafone P
.183 226104 vodafone P
.184 227106 vodafone P
.185 228109 vodafone P
.186 229110 vodafone P
.187 230118 vodafone P
.188 231119 vodafone P
.189 232123 vodafone P
.190 233126 vodafone P
.191 234138 vodafone P
.192 235152 vodafone P
.193 236167 vodafone P
.194 237179 vodafone P
.195 238191 vodafone P
.196 239205 vodafone P
.197 240220 vodafone P
.198 241230 vodafone P
.199 242241 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.200 244408 vodafone P
.201 245415 vodafone P
.202 246419 vodafone P
Received from cloud:
True
.203 247432 vodafone P
.204 248434 vodafone P
.205 249437 vodafone P
.206 250441 vodafone P
.207 251452 vodafone P
.208 253238 vodafone P
.209 254244 vodafone P
.210 255248 vodafone P
.211 256249 vodafone P
.212 257252 vodafone P
.213 258255 vodafone P
.214 259260 vodafone P
.215 260262 vodafone P
.216 261263 vodafone P
.217 262267 vodafone P
.218 263273 vodafone P
.219 264286 vodafone P
.220 265295 vodafone P
.221 266309 vodafone P
.222 267318 vodafone P
.223 268332 vodafone P
.224 269353 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.225 271320 vodafone P
.226 272334 vodafone P
Received from cloud:
True
.227 273875 vodafone P
.228 274881 vodafone P
.229 275886 vodafone P
.230 278072 vodafone P
.231 279084 vodafone P
.232 280085 vodafone P
.233 281106 vodafone P
.234 282112 vodafone P
.235 283115 vodafone P
.236 284118 vodafone P
.237 285121 vodafone P
.238 286125 vodafone P
.239 287130 vodafone P
.240 288147 vodafone P
.241 289162 vodafone P
.242 290176 vodafone P
.243 291191 vodafone P
.244 292209 vodafone P
.245 293223 vodafone P
.246 294238 vodafone P
.247 295254 vodafone P
.248 296269 vodafone P
.249 297289 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.250 299330 vodafone P
.251 300333 vodafone P
.252 302095 vodafone P
Received from cloud:
True
.253 303098 vodafone P
.254 304099 vodafone P
.255 305101 vodafone P
.256 306106 vodafone P
.257 307125 vodafone P
.258 308323 Not available
.259 309332 vodafone P
.260 310336 vodafone P
.261 311339 vodafone P
.262 312345 vodafone P
.263 313348 vodafone P
.264 314353 vodafone P
.265 315356 vodafone P
.266 316359 vodafone P
.267 317365 vodafone P
.268 318369 vodafone P
.269 319384 vodafone P
.270 320398 vodafone P
.271 321409 vodafone P
.272 322424 vodafone P
.273 323439 vodafone P
.274 324454 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.275 326490 vodafone P
.276 327494 vodafone P <------- DEADLOCK HERE
If you take a look at the output above, there ate two things here:
- On the second
.152
, I could not get the string (True) back from the cloud - On the second
.276
, as soon as we should have the cloud handler being executed, there was a deadlock on the code. Where it stays like this forever. I could unblock this only by sending manually a message to theport 4444
using the known API:
Is this a firmware bug?
PS:
The .276
second was random, because if I re-test this it can enter the deadlock at another time, for example see the test I’ve made right after:
.0 29796 vodafone P
.1 30813 vodafone P
.2 31819 vodafone P
.3 32826 vodafone P
.4 33833 vodafone P
.5 34840 vodafone P
.6 35856 vodafone P
.7 36867 vodafone P
.8 37868 vodafone P
.9 38873 vodafone P
.10 39879 vodafone P
.11 40884 vodafone P
.12 41885 vodafone P
.13 42891 vodafone P
.14 44429 Not available
.15 45450 vodafone P
.16 46454 vodafone P
.17 47470 vodafone P
.18 48481 vodafone P
.19 49494 vodafone P
.20 50510 vodafone P
.21 51523 vodafone P
.22 52539 vodafone P
.23 53558 vodafone P
.24 54573 vodafone P
Sending to cloud = topic: TESTTOPIC msg: {"test":"987654321"}
Msg was sent to Cloud :)
.25 57317 vodafone P
.26 58322 vodafone P
.27 59331 vodafone P
.28 60336 vodafone P <------- DEADLOCK HERE
I’m using:
Board version: 0.11.0
Dash Boot Version: 3.1.1
Dash Boot Version Number: 196865
Hologram Cloud System Version: 0.10.1
Thank you,
jpgl