   if(error){
     return error;
   }
-  int port = strToInt(portQuery);
+  uint8_t port = strToInt(portQuery);
+  return diRead(port);
+}
+
+String diRead(uint8_t port){
   int val = digitalRead(port);
   return ioReturnJson("OK", port, val);
 }

    return error;
  }
  int port = strToInt(portQuery);
  int val = analogRead(port);
  return ioReturnJson("OK", port, val);
}

      }
    }
  }

  // enabledがtrueかつ、portsのどれか一つが有効になっていれば
  // 変換を行う
  if(di_stream_info.enabled &&
     di_stream_info.ports != 0){
    Serial.print(eventResponseHeader("di"));
    bool first = true;
    for(int i = 0; i < 14; i++){
      if(bitRead(di_stream_info.ports, i) == 1){
        if(first){
          first = false;
        }else{
          Serial.print(",");
        }
        Serial.print(diRead(i));
      }
    }
    Serial.println("]}");
  }

  if(ai_stream_info.enabled &&
     ai_stream_info.ports != 0){
    Serial.print(eventResponseHeader("ai"));
    bool first = true;
    for(int i = 0; i < 14; i++){
      if(bitRead(ai_stream_info.ports, i) == 1){
        if(first){
          first = false;
        }else{
          Serial.print(",");
        }
        Serial.print(aiRead(i));
      }
    }
    Serial.println("]}");
  }
}

String eventResponseHeader(String event){
  return "{" + stringJson("event", event) + "," + wrapDq("datas") + ":[";
}

String boolJson(String key, bool value){
  String str = value ? "true" : "false";
  return wrapDq(key) + ":" + str;
}

String intJson(String key, int value){
  return wrapDq(key) + ":" + String(value);
}

String stringJson(String key, String value){
  return wrapDq(key) + ":" + wrapDq(value);
}

String task(String msg){
  // 関数テーブルからタスクを決定する.
