For test

Dependencies:   mbed

Revision:
20:43451f36281e
Parent:
19:6c8b29734511
--- a/ArduinoSerial.cpp	Wed Feb 04 09:28:28 2015 +0000
+++ b/ArduinoSerial.cpp	Wed Feb 04 09:39:10 2015 +0000
@@ -8,14 +8,13 @@
     for (p = ms_list_head.next; p != &ms_list_head; p = p->next) {
         if (p->data != NULL) {
             while(p->data->readable()) {
-                p->data->write_char(p->data->getc());
+                p->data->writeChr(p->data->getc());
             }
         }
     }
 }
 
 ArduinoSerial::ArduinoSerial(PinName tx, PinName rx):Serial(tx, rx) {
-    
     ms_instance_counter++;
     if (ms_instance_counter == 1) {
         initHeadNode(&ms_list_head);
@@ -44,13 +43,12 @@
     return (unsigned int)(ARDUINOSERIAL_BUFFER_SIZE + m_rx_buffer.head - m_rx_buffer.tail) % ARDUINOSERIAL_BUFFER_SIZE;
 }
 
-/* 清空接收缓冲区的数据 */
 void ArduinoSerial::flush(void)
 {
     memset(&m_rx_buffer, 0, sizeof(m_rx_buffer));
 }
 
-char ArduinoSerial::read_char(void) {
+char ArduinoSerial::readChr(void) {
     // if the head isn't ahead of the tail, we don't have any characters
     if (m_rx_buffer.head == m_rx_buffer.tail) {
         return (char)-1;
@@ -65,7 +63,6 @@
     m_find_timeout = millisecond;
 }
 
-/* 在超时之前, 如果在串口接收数据缓冲区中找到了定长字符串 str 就返回 true, 如果超时, 返回 false */
 bool ArduinoSerial::find(const char *str) {
     bool ret = false;
     String data;
@@ -73,14 +70,14 @@
     unsigned long i;
     for (i = 0; i < m_find_timeout; i++) {
         while(available() > 0) {
-            c = read_char();
+            c = readChr();
             data += c;
         }
         if (data.indexOf(String(str)) != -1) {
             ret = true;
             break;
         }
-        delay(1);
+        wait_ms(1);
     }
     return ret;
 }
@@ -90,7 +87,7 @@
     return 1;
 }
 
-void ArduinoSerial::write_char(unsigned char c) {
+void ArduinoSerial::writeChr(unsigned char c) {
     int i = (unsigned int)(m_rx_buffer.head + 1) % ARDUINOSERIAL_BUFFER_SIZE;
 
     // if we should be storing the received character into the location
@@ -118,11 +115,11 @@
     if (node == NULL) {
         return NULL;
     }
-    /* 设置该节点的值 */
+    /* Setting node */
     node->data = data;
     node->next = head;
     
-    /* 在末尾插入该节点 */
+    /* Add node to tail */
     for(p = head; p->next != head; p = p->next);
     p->next = node;