[問題] 程式疑問
各位板上的高手好,小弟是一個大三生,目前在做cc3200的專題,碰到了一些困難還請各位指點:
具小弟我的理解cc3200在get時應該是從html call ccs裡的callback function,並讀取板子上的資訊將標籤替換。
Callback funtion的部分 如下:
if(memcmp(pSlHttpServerEvent->EventData.httpTokenName.data, GET_sw,
strlen((const char *)GET_sw)) == 0)
{
status = getswstatus();
strLenVal = strlen(SW_STRING);
memcpy(ptr, SW_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
if(status & 0x01)
{
strLenVal = strlen(SW_ON_STRING);
memcpy(ptr, SW_ON_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
}
else
{
strLenVal = strlen(SW_OFF_STRING);
memcpy(ptr, SW_OFF_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
}
*ptr = '\0';
}
Html 如下:
function UpdateStatus()
{
window.sessionStorage.clear()
var status = '__SL_G_USW;
if(status.indexOf("SW_ON") > -1)
{
toggleSwitch ('on');
alert('Hi, I am alert box.');
}
else
{
toggleSwitch ('off');
}
}
讀取一次時沒問題,但當我在html檔裡加
setInterval(function(){UpdateStatus()}, 1000);
時卻發現他在重新讀取時__SL_G_USW會直接被替換為一開始的SW_ON(OFF)值,我該如何才能讓程式讀取當前板子上的值,還請高手指點。
另外請教各位大大如果要做這片板子除了C、javascript還需要會什麼程式??我實在找不到方向,麻煩各位了,謝謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.226.129.46
※ 文章網址: https://www.ptt.cc/bbs/Electronics/M.1458223433.A.29A.html
※ 編輯: ortontherko (36.226.129.46), 03/17/2016 22:05:02
※ 編輯: ortontherko (36.226.129.46), 03/17/2016 22:05:34
→
03/18 23:04, , 1F
03/18 23:04, 1F