This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Im trying to complete a very simple thing - open a socket and send string "hello" every second.
If I use send command then I receive one "hello" string on the server, but then the execution hangs in hci_event_handler() on the following line:
if (tSLInformation.usEventOrDataReceived != 0)
Seems like its expecting some data back?
If I use a sendto command without connect then it doesn't hang but I also receive nothing on the server.
My final task is to continuously stream data to the open socket. Anybody has an idea on whats going wrong there?
Here is my code:
int socket_handle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
tSocketAddr.
sa_family = AF_INET;
unsigned long port;
port = htons(1234);
memcpy(&tSocketAddr.sa_data[0], &port, sizeof(unsigned short));
// IP addr of server
unsigned long ulIpAddr;
ulIpAddr = htonl(3232281170);
//192.168.0.1
memcpy(&tSocketAddr.sa_data[2], (unsigned char*)&ulIpAddr, 4);
//SysCtlDelay(10000);
char sendmsg[5]="Hello";
if(socket_handle!=-1)
{
connect(socket_handle, &tSocketAddr,
sizeof(tSocketAddr));
P1DIR |=BIT3;
while(1)
{
//sendto(socket_handle, &sendmsg, sizeof(sendmsg), 0, &tSocketAddr, sizeof(sockaddr));
send(socket_handle, &sendmsg,
sizeof(sendmsg), 0);
P1OUT ^=BIT3;
__delay_cycles(1000000);
}
}
Ok, sendto only works for UDP packaets - please fix that in SDK as in comments for the function it says TCP.
But the problem with hanging send is still there - anyone ideas?
My UDP socket sendto() calls are also hanging. I'm using the example code from the wiki almost verbatim:
sockaddr tSocketAddr;
char McastPacketTx[] = { 'd', 'a', 't', 'a' };
// create MCAST address 192.168.1.255 port 50007
tSocketAddr.sa_family = AF_INET;
// Destination port
tSocketAddr.sa_data[0] = 195;
tSocketAddr.sa_data[1] = 87;
// Destination IP address
tSocketAddr.sa_data[2] = 192;
tSocketAddr.sa_data[3] = 168;
tSocketAddr.sa_data[4] = 1;
tSocketAddr.sa_data[5] = 0xFF;
int McastPacketTxLen = 4;
long ulTxSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
//Send the multicast packet
sendto(ulTxSocket, McastPacketTx, McastPacketTxLen, 0, &tSocketAddr,
sizeof(sockaddr));
I don't know when this started because up until now I had only been using recv(), recvfrom() and send(). I am on the latest service pack. The above code is run immediately after the DHCP event is received, and hangs on the sendto() within hci_event_handler().
Hi Vishal
What service pack (patches) are you using? We've added command complete to both send/sendto commands starting from V1.11. This change requires updated host as well.
Else, if you took the latest SDK examples, then you must update to the latest patches.
Regards,
Tomer
Hi Everybody!
I have the same problem, if use the Home Automation example ( I just modified to send a "hello" string and don't receive data) my first data has arrived, but then nothing.
If I comment the
//SimpleLinkWaitEvent(HCI_EVNT_SEND, &tSocketSendEvent);
parts in the
int simple_link_send(long sd, const void *buf, long len, long flags, const sockaddr *to, long tolen, long opcode)
function, and add a little delay, it works fine.
The weird thing is, the original Home Automation example works fine on the FRAM Kit with Murata WiFi module, but doesn't works with the TI CC3000 WiFi module. But of course, every other parts of the project ( Smart Config, data receiving, etc. ) also works fine with the TI module.
I use the latest patch version in both case.
Any idea?
Hi All
I have encountered exactly the same problem as is described above. I have an MSP430F5529 Launch Pad and a CC3000 Boost. I am trying to use UDP to send a short string to another device on the network. I am using SendTo and the string is being received by the other device but the CC3000 Host Driver then ends up in a loop in hci_event_handler(). It is waiting for tSLInformation.usEventOrDataReceived to be set to a value other than zero and this never happens.
I tried debugging the code and found that the Simple_Link_Send() contains the following:
// Initiate a HCI command
hci_data_send(opcode, ptr, uArgSize, len,(unsigned char*)to, tolen);
if (opcode == HCI_CMND_SENDTO)
SimpleLinkWaitEvent(HCI_EVNT_SENDTO, &tSocketSendEvent);
else
SimpleLinkWaitEvent(HCI_EVNT_SEND, &tSocketSendEvent);
It seems that the data is sent and then the SimpleLinkWaitEvent() method calls the hci_event_handler which goes into a loop. I assume that there should be an Interrrupt which triggers an exit from the loop. I found that there is an interrupt but after it has been processed tSLInformation.usEventOrDataReceived is still zero and so the code doesn't exit from the loop.
I saw in the previous post that commenting out the SimpleLinkWaitEvent() method call in the SimpleLinkSend() method and adding a delay fixed the problem. I tried this and everything now seems to work but this seems like a bit of hack, is it what TI would recommend or is there a better fix for this issue.
Hi.
Later I figured out, the problem was with the patch, not with the device.
Because the TI modules came with the 1.0 patch, and when I tried to upgrade them I did something incorrectly (I don't know, what was the problem, maybe the MCU starts the Driver patch again before the firmware patch upgrade, and this was the problem), and the v1.0 patch remains on the device, despite of the successfully upgrade (I looks like successfully, but It wasn't)
When I really upgraded the patch to v1.1, the same hardware and software works fine.
So in my situation, the incorrect firmware upgrade was the problem.
Hi,
Thanks for your response, it pointed me in the right direction. I downloaded and installed the latest patches and this seems to have fixed the problem.