TCPClient problem connecting - help please

Hi @peekay123, would you please email me the example that you mentioned as a workaround for client.flush() problem?

Thanks.

@srvn13, the work around is simple. Once you’ve received your response from the server, you flush the CC3000 queue using read():

while (client.available())
char c = client.read();

@bko has pointed out that to be prudent, timeouts should be added like this:

unsigned long startTime = millis();
while (client.available() == false && millis() - startTime < 1000) {
// Just wait up to 1000 millis
}
startTime = millis();
while (client.available() > 0 && millis() - startTime < 1000) {
client.read();
}

The first timeout is to make sure the server has actually stopped responding with data. The second is to make sure the look does not run forever. :smile:

2 Likes

Thanks for the quick response.

1 Like

Hi All,

I am experiencing the same problem again. The codes work to connect initially but as soon as I added any other line to the code (such as simply declare another variable) the Core stops connecting again.

Also, I am using IDE Dev downloaded from Spark.io site on my PC.
I thought maybe I have an old version, so I downloaded and installed it again now… still have the same problem.

Here is the log from the IDE - anyone can look at it and let me know what is the problem?

*** Log begins ***
Failed to activate package named ‘metrics’ Error: Cannot find module 'getmac’
at Module._resolveFilename (module.js:344:15)
at Function.Module._resolveFilename (c:\Program Files (x86)\Spark Dev\resources\app\src\module-cache.js:380:52)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:373:17)
at require (module.js:392:17)
at Object.module.exports.getUserId (c:\Program Files (x86)\Spark Dev\resources\app\node_modules\metrics\lib\metrics.js:49:14)
at Object.module.exports.activate (c:\Program Files (x86)\Spark Dev\resources\app\node_modules\metrics\lib\metrics.js:15:14)
at Package.module.exports.Package.activateNow (c:\Program Files (x86)\Spark Dev\resources\app\src\package.js:225:27)
at c:\Program Files (x86)\Spark Dev\resources\app\src\package.js:211:28
at Package.module.exports.Package.measure (c:\Program Files (x86)\Spark Dev\resources\app\src\package.js:157:15)
at Package.module.exports.Package.activate (c:\Program Files (x86)\Spark Dev\resources\app\src\package.js:205:14)
at PackageManager.module.exports.PackageManager.activatePackage (c:\Program Files (x86)\Spark Dev\resources\app\src\package-manager.js:404:21)
at PackageManager.module.exports.PackageManager.activatePackages (c:\Program Files (x86)\Spark Dev\resources\app\src\package-manager.js:393:14)
at PackageManager.module.exports.PackageManager.activate (c:\Program Files (x86)\Spark Dev\resources\app\src\package-manager.js:379:19)
at Atom.module.exports.Atom.startEditorWindow (c:\Program Files (x86)\Spark Dev\resources\app\src\atom.js:516:21)
at Object. (c:\Program Files (x86)\Spark Dev\resources\app\src\window-bootstrap.js:12:8)
at Object. (c:\Program Files (x86)\Spark Dev\resources\app\src\window-bootstrap.js:23:4)
at Module._compile (module.js:468:26)
at Object.Module._extensions…js (module.js:486:10)
at Module.load (c:\Program Files (x86)\Spark Dev\resources\app\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
at Function.Module._load (module.js:318:12)
at Module.require (module.js:373:17)
at require (module.js:392:17)
at window.onload (file:///C:/Program%20Files%20(x86)/Spark%20Dev/resources/app/static/index.js:34:25)
c:\Program Files (x86)\Spark Dev\resources\app\src\package.js:230
Window load time: 14593ms index.js:39
Uncaught Error: ENOENT, unlink ‘c:\Users\KimL\Documents\Spark files\Test8\firmware_1429883700705.bin’ fs.js:75
Uncaught Error: Cannot find module ‘request’ module.js:346

*** Log ends **