Changeset 143


Ignore:
Timestamp:
Dec 5, 2015, 7:18:45 PM (7 years ago)
Author:
ertl-honda
Message:

Milkcocoa用に更新

Location:
rtos_arduino/trunk/arduino_lib/libraries/ESP8266
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • rtos_arduino/trunk/arduino_lib/libraries/ESP8266/ESP8266.cpp

    r136 r143  
    77 * @par Copyright:
    88 * Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n
     9 * Copyright (C) 2015 Embedded and Real-Time Systems Laboratory
     10 *              Graduate School of Information Science, Nagoya Univ., JAPAN \n\n
    911 * This program is free software; you can redistribute it and/or
    1012 * modify it under the terms of the GNU General Public License as
     
    2325#define LOG_OUTPUT_DEBUG            (1)
    2426#define LOG_OUTPUT_DEBUG_PREFIX     (1)
     27
     28#ifdef TOPPERS_WITH_ARDUINO
     29#define WAIT_TIMEOUT delay(1);
     30#else /* !TOPPERS_WITH_ARDUINO */
     31#define WAIT_TIMEOUT
     32#endif /* TOPPERS_WITH_ARDUINO */
    2533
    2634#define logDebug(arg)\
     
    4351
    4452#ifdef ESP8266_USE_SOFTWARE_SERIAL
    45 ESP8266::begin(SoftwareSerial &uart, uint32_t baud)
     53void ESP8266::begin(SoftwareSerial &uart, uint32_t baud)
    4654{
    4755    m_puart = &uart;
    4856    m_baud = baud;
    4957    m_puart->begin(baud);
    50     rx_empty();           
     58    rx_empty();
    5159}
    5260#else
     
    5664    m_baud = baud;
    5765    m_puart->begin(baud);
    58     rx_empty();       
     66    rx_empty();
    5967}
    6068#endif
     
    306314}
    307315
     316int ESP8266::dataAvailable(void)
     317{
     318    return (m_puart->available() > 0)? 1 : 0;
     319}
     320           
    308321/*----------------------------------------------------------------------------*/
    309322/* +IPD,<id>,<len>:<data> */
     
    334347            data += a;
    335348        }else{
    336             delay(1);
     349            WAIT_TIMEOUT;
    337350        }
    338351       
     
    366379    if (has_data) {
    367380        i = 0;
    368         ret = len > buffer_size ? buffer_size : len;
     381        ret = (uint32_t)len > buffer_size ? buffer_size : len;
    369382        start = millis();
    370383        while (millis() - start < 3000) {
     
    383396                return ret;
    384397            }
    385             delay(1);
     398            WAIT_TIMEOUT
    386399        }
    387400    }
     
    410423            break;
    411424        }
    412         delay(1);
     425        WAIT_TIMEOUT
    413426    }
    414427    return data;
     
    416429
    417430String ESP8266::recvString(String target1, String target2, uint32_t timeout)
    418 {
    419     String data;
    420     char a;
    421     unsigned long start = millis();
    422     while (millis() - start < timeout) {
    423         while(m_puart->available() > 0) {
    424             a = m_puart->read();
    425                         if(a == '\0') continue;
    426             data += a;
    427         }
    428         if (data.indexOf(target1) != -1) {
    429             break;
    430         } else if (data.indexOf(target2) != -1) {
    431             break;
    432         }
    433         delay(1);
    434     }
    435     return data;
    436 }
    437 
    438 String ESP8266::recvString(String target1, String target2, String target3, uint32_t timeout)
    439431{
    440432    String data;
     
    451443        } else if (data.indexOf(target2) != -1) {
    452444            break;
     445        }
     446        WAIT_TIMEOUT
     447    }
     448    return data;
     449}
     450
     451String ESP8266::recvString(String target1, String target2, String target3, uint32_t timeout)
     452{
     453    String data;
     454    char a;
     455    unsigned long start = millis();
     456    while (millis() - start < timeout) {
     457        while(m_puart->available() > 0) {
     458            a = m_puart->read();
     459            if(a == '\0') continue;
     460            data += a;
     461        }
     462        if (data.indexOf(target1) != -1) {
     463            break;
     464        } else if (data.indexOf(target2) != -1) {
     465            break;
    453466        } else if (data.indexOf(target3) != -1) {
    454467            break;
    455468        }
    456         delay(1);
     469        WAIT_TIMEOUT
    457470    }
    458471    return data;
  • rtos_arduino/trunk/arduino_lib/libraries/ESP8266/ESP8266.h

    r136 r143  
    77 * @par Copyright:
    88 * Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n
     9 * Copyright (C) 2015 Embedded and Real-Time Systems Laboratory
     10 *              Graduate School of Information Science, Nagoya Univ., JAPAN \n\n 
    911 * This program is free software; you can redistribute it and/or
    1012 * modify it under the terms of the GNU General Public License as
     
    4143#ifdef ESP8266_USE_SOFTWARE_SERIAL
    4244    /*
    43      * Constuctor.
     45     * Begin.
    4446     *
    4547     * @param uart - an reference of SoftwareSerial object.
     
    5153#else /* HardwareSerial */
    5254    /*
    53      * Constuctor.
     55     * Begin.
    5456     *
    5557     * @param uart - an reference of HardwareSerial object.
     
    402404     */
    403405    uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
     406
     407    /**
     408     * Check data is available.
     409     *
     410     * @return 1 : data is available, 0 : data is not available
     411     */
     412    int dataAvailable(void);
    404413
    405414 private:
  • rtos_arduino/trunk/arduino_lib/libraries/ESP8266/README.md

    r136 r143  
    11@mainpage
    22
    3 # WeeESP8266
     3# WeeESP8266 updated for Milkcoca SDK
    44
    55An ESP8266 library for Arduino providing an easy-to-use way to manipulate ESP8266.
     6Updated to support Milkcoca SDK<>, M0 and TOPPERS/R2CA.
    67
    78# Source
    8 
    9 Source can be download at <https://github.com/itead/ITEADLIB_Arduino_WeeESP8266>.
     9Source can be download at <>.
     10Original source can be download at <https://github.com/itead/ITEADLIB_Arduino_WeeESP8266>.
    1011
    1112You can clone it by:
     
    9394    uint32_t    recv (uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) : Receive data from all of TCP or UDP builded already in multiple mode.
    9495
     96# Added API List
     97
     98    void        begin(SoftwareSerial &uart, uint32_t baud = 115200); : Begin ESP8266.
     99
     100    void        begin(SoftwareSerial &uart, uint32_t baud = 115200); : Begin ESP8266.
     101
     102    bool        send(String &str); : Send data based on TCP or UDP builded already in single mode.
     103
     104    bool        send(uint8_t mux_id, String &str); : Send data based on one of TCP or UDP builded already in multiple mode.
     105
     106    int         dataAvailable(void); : Check data is available.
    95107
    96108# Mainboard Requires
     
    103115  - Arduino UNO and its derivatives
    104116  - Arduino MEGA and its derivatives
     117  - Arduino M0 and its derivatives
    105118  - [Iteaduino UNO](http://imall.iteadstudio.com/im130312001.html)
    106119  - [WBoard Pro](http://imall.iteadstudio.com/im141125005.html)
     
    165178defined in HardwareSerial.h is too small.
    166179
     180UNO or MEGA or WBoard Pro
    167181Open the file from `\arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h`.
    168 See the follow line in the HardwareSerial.h file.
     182
     183M0
     184Open the file from `\arduino\hardware\arduino\avr\cores\arduino\RingBuffer.h`.
     185See the follow line in the file.
    169186
    170187    #define SERIAL_BUFFER_SIZE 64
Note: See TracChangeset for help on using the changeset viewer.