Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 27 of 27

Thread: CC3000 with Teensy3.1

  1. #26
    Junior Member
    Join Date
    Feb 2014
    Posts
    7
    Great news!

    I didn't quite understand what solved the problem. Just the println or is the energia library also required?

  2. #27
    Senior Member johnnyfp's Avatar
    Join Date
    Jan 2014
    Location
    New Zealand
    Posts
    260
    Was just rambling.

    So the Energia library is required in place of the adafruit one. With several tweaks required to it as detailed in an earlier post, and then another tweak required to the TCPclient write method.
    This currently goes into a loop and counts down the number of bytes to send, however if a SPI error happens the HCI driver returns a -1 to indicate that an error occurred, the code then add's that to the index which is wrong as it will skew the pointer and potentially buffer underrun. Which is not good.

    Eg
    Code:
       int strlen = size,i = 0;
    
    	if(size == 0) return 0;
    
    	do{
    
    		if(strlen-i<TX_BUF_SIZE){
    			i += send(((long)clientSocket)&0xFF, buf+i, strlen-i, 0);
    		}
    		else {
    			i += send(((long)clientSocket)&0xFF, buf+i, TX_BUF_SIZE, 0);
    		}
    
    	}while( i < strlen);
    
    	return strlen;
    So the highlighted red would be bad if the send errors as a -1 is sent, but the code doesn't check for errors.

    So instead It would need to be
    Code:
    int strlen = size,i = 0,r = 0, retry = 3;
    
    	if(size == 0) return 0;
    
    	do{
    		if(strlen-i<TX_BUF_SIZE){
    			r=send(((long)clientSocket)&0xFF, buf+i, strlen-i, 0);
    		}
    		else {
    			r=send(((long)clientSocket)&0xFF, buf+i, TX_BUF_SIZE, 0);
    		}
    		if (r<0) retry--;
    		else {
    		  i+=r;
    		  retry=3;
    		}
    	}while( i < strlen && retry>0);
    
    
    	return strlen;
    But aside from that, it still not entirely fixed. I've seen it get stuck somewhere in the socket accept and still need to find out why the send is erroring.

    But I will get there. Once I do I will release my copy of the library (need to check if I can do that, license wise). And hopefully we'll have a stable WifiLink library for the teensy.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •