Hi,
Scenario:
Just like most examples from CC3200 sdk, I created a new task for initializing Simplelink, connecting to an AP and setting up a TCP socket server within an single FreeRTOS task.
After a client has been connected to CC3200 (using nodejs), the CC3200 client socket will be set as NON-BLOCKING socket, and the simplelink task started initializing camera module etc and start receiving DMA and end-of-frame interrupts CONTINUOUSLY.
The difference between my application and the Websocket Camera example is that, I NEVER STOP the camera, and all image frames are continuously feeded into a circular buffer(with some properties to remember all starting points of a frame).
When a new frame was detected (in a while loop checking if new frames are buffered in, everything here is 100% correct), that Simplelink task start sending the frame over the connected socket. HOWEVER, non of the data were actually being received from client side (nodejs), not at all, not a bit. After about 6KB ~ 30KB of data being "SENT" from CC3200, the sl_Send started reporting error code -11 (note: it's been set to NON-BLOCKING socket), which is TRY_AGAIN.
However, if I get rid of Camera module for a moment, only sending 1000 arrays of 1024 sized buffer to the socket, everything just go fine, so I'm very curious whether the camera module holds an higher priority and the WiFi process never get a chance to send the data?
Anyone has any idea?
int camera_send_frame (int sock, uint8_t* buf, uint32_t len, int mode) { mediap_t sock_media; int media_sent = 0; int snd, snt; //long lNonBlocking = 0; sock_media.magic = 0xFEED; sock_media.meta = mode; sock_media.image_width = x_pixels_size; sock_media.image_height = y_pixels_size; sock_media.length = len; // try sync mode //int iStatus = sl_SetSockOpt(sock, SL_SOL_SOCKET, SL_SO_NONBLOCKING, &lNonBlocking, sizeof(lNonBlocking)); // Send data over socket UART_PRINT("Sending %d bytes via socket \n\r", len); while (len > 0) { if (!media_sent) { snt = sl_Send (sock, &sock_media, sizeof(sock_media), 0); UART_PRINT("SND: %d, SNT: %d \n\r", sizeof(sock_media), snt); media_sent = 1; } snd = len > 1024? 1024: len; snt = sl_Send (sock, buf, snd, 0); UART_PRINT("SND: %d, SNT: %d \n\r", snd, snt); if (snt == SL_EAGAIN || !snt) continue; if (snt < 0) { return CAMERA_ERROR_SOCKET; } buf += snt; len -= snt; } return mode; } int camera_shoot_video (int sock, int* control) { int index = 0; int cmd = CAMERA_VIDEO_MODE; int err = CAMERA_VIDEO_MODE; MAP_CameraCaptureStart(CAMERA_BASE); while (*control) { UART_PRINT("WAITING FOR a FRAME \n\r"); while (!image_buffer.frame_loc[index] && !frame_error); if (frame_error) { return CAMERA_ERROR_FRAME_OVERFLOW; } UART_PRINT("FRAME DONE \n\r"); uint8_t* buf = (uint8_t*)image_buffer.frame_loc[index]; uint32_t len = image_buffer.frame_sz[index]; image_buffer.frame_loc[index] = NULL; image_buffer.frame_sz[index] = 0; index = (++index)%2; // Send data over socket err = camera_send_frame(sock, buf, len, CAMERA_VIDEO_MODE); if (err != CAMERA_VIDEO_MODE) break; // receive cmd from sock int16_t rcvd = sl_Recv(sock, &cmd, 1, 0); if (rcvd == SL_EAGAIN || !rcvd) continue; if (rcvd < 0) { err= CAMERA_ERROR_SOCKET; break; } err = cmd; break; } MAP_CameraCaptureStop(CAMERA_BASE, true); return err; }
The logs below illustrates that initially, sl_Send sends some data "Successfully" which is not because the client side(nodejs) has never received any data. Then after it continues returning error code -11.
[CAMERA MODULE] init camera done. WAITING FOR a FRAME # CI EOF 27 FRAME DONE Sending 6912 bytes via socket SND: 12, SNT: 12 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 768, SNT: 768 WAITING FOR a FRAME # CI EOF 28 FRAME DONE Sending 7168 bytes via socket SND: 12, SNT: 12 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 WAITING FOR a FRAME # CI EOF 28 FRAME DONE Sending 7168 bytes via socket SND: 12, SNT: 12 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 WAITING FOR a FRAME # CI EOF 32 FRAME DONE Sending 8192 bytes via socket SND: 12, SNT: 12 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 WAITING FOR a FRAME # CI EOF 32 FRAME DONE Sending 8192 bytes via socket SND: 12, SNT: 12 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 WAITING FOR a FRAME # CI EOF 32 FRAME DONE Sending 8192 bytes via socket SND: 12, SNT: 12 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 WAITING FOR a FRAME # CI EOF 32 FRAME DONE Sending 8192 bytes via socket SND: 12, SNT: 12 SND: 1024, SNT: 1024 SND: 1024, SNT: 1024 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11 SND: 1024, SNT: -11