Arduino와 통신해야하는 C# 프로그램을 작성하고 있습니다. 기본적으로 데이터를 전송하기 때문에 직렬 모니터에서 읽을 수 있어야합니다.Arduino 직렬 통신이 이상하게 작동합니다.
C# 코드 :
if (errCheck[i].IsChecked.GetValueOrDefault() == true)
err = "1"+err;
else
err = "0"+err;
_serialPort.Write("<16,"+ Convert.ToUInt32(err,2) + ">");
아두 이노 코드 : 마지막 확인란이 선택되어
void parseData() { // split the data into its parts
char * strtokIndx; // this is used by strtok() as an index
//strtokIndx = strtok(tempChars,","); // get the first part - the string
//strcpy(messageFromPC, strtokIndx); // copy it to messageFromPC
strtokIndx = strtok(tempChars, ","); // this continues where the previous call left off
integerFromPC = atoi(strtokIndx); // convert this part to an integer
switch (integerFromPC) {
//all cases
case 16: //managing errors
delay(10);
strtokIndx = strtok(NULL, ",");
uint32_tFromPC = atoi(strtokIndx);
errors=uint32_tFromPC;
Serial.print("errors Updated");
은 (나의 진 스트링 1, 31 0 '이다) 시리얼 모니터가 7F FF FF FF
대신 80 00 00 00
읽습니다.
ulong
을 사용해 보았습니다. 그러나 어떤 아이디어도 효과가없는 것 같습니까?
내가 1and31 0의이 –