<commit_before>/*
 * This file is part of Espruino, a JavaScript interpreter for Microcontrollers
 *
 * Copyright (C) 2013 <NAME> <<EMAIL>>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * ----------------------------------------------------------------------------
 * This file is designed to be parsed during the build process
 *
 * JavaScript Serial Port Functions
 * ----------------------------------------------------------------------------
 */
#include "jswrap_serial.h"
#include "jsdevices.h"
#include "jsinteractive.h"

/*JSON{
  "type" : "class",
  "class" : "Serial"
}
This class allows use of the built-in USARTs

Methods may be called on the USB, Serial1, Serial2, Serial3, Serial4, Serial5 and Serial6 objects. While different processors provide different numbers of USARTs, you can always rely on at least Serial1 and Serial2
 */
/*JSON{
  "type" : "event",
  "class" : "Serial",
  "name" : "data",
  "params" : [
    ["data","JsVar","A string containing one or more characters of received data"]
  ]
}
The `data` event is called when data is received. If a handler is defined with `X.on('data', function(data) { ... })` then it will be called, otherwise data will be stored in an internal buffer, where it can be retrieved with `X.read()`
 */

/*JSON{
  "type" : "event",
  "class" : "Serial",
  "name" : "framing"
}
The `framing` event is called when there was activity on the input to the UART
but the `STOP` bit wasn't in the correct place. This is either because there
was noise on the line, or the line has been pulled to 0 for a long period
of time.

**Note:** Even though there was an error, the byte will still be received and
passed to the `data` handler.
 */
/*JSON{
  "type" : "event",
  "class" : "Serial",
  "name" : "parity"
}
The `parity` event is called when the UART was configured with a parity bit,
and this doesn't match the bits that have actually been received.

**Note:** Even though there was an error, the byte will still be received and
passed to the `data` handler.
 */
// this is created in jsiIdle based on EV_SERIALx_STATUS ecents

/*JSON{
  "type" : "staticmethod",
  "class" : "Serial",
  "name" : "find",
  "generate_full" : "jshGetDeviceObjectFor(JSH_USART1, JSH_USARTMAX, pin)",
  "params" : [
    ["pin","pin","A pin to search with"]
  ],
  "return" : ["JsVar","An object of type `Serial`, or `undefined` if one couldn't be found."]
}
Try and find a USART (Serial) hardware device that will work on this pin (eg. `Serial1`)

May return undefined if no device can be found.
*/


/*JSON{
  "type" : "object",
  "name" : "USB",
  "instanceof" : "Serial",
  "#ifdef" : "USB"
}
The USB Serial port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial1",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=1"
}
The first Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial2",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=2"
}
The second Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial3",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=3"
}
The third Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial4",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=4"
}
The fourth Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial5",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=5"
}
The fifth Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial6",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=6"
}
The sixth Serial (USART) port
 */

/*JSON{
  "type" : "object",
  "name" : "LoopbackA",
  "instanceof" : "Serial"
}
A loopback serial device. Data sent to LoopbackA comes out of LoopbackB and vice versa
 */
/*JSON{
  "type" : "object",
  "name" : "LoopbackB",
  "instanceof" : "Serial"
}
A loopback serial device. Data sent to LoopbackA comes out of LoopbackB and vice versa
 */


<commit_msg>add Telnet as a serial device so one can communicate with an attached console<commit_after>/*
 * This file is part of Espruino, a JavaScript interpreter for Microcontrollers
 *
 * Copyright (C) 2013 <NAME> <<EMAIL>>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * ----------------------------------------------------------------------------
 * This file is designed to be parsed during the build process
 *
 * JavaScript Serial Port Functions
 * ----------------------------------------------------------------------------
 */
#include "jswrap_serial.h"
#include "jsdevices.h"
#include "jsinteractive.h"

/*JSON{
  "type" : "class",
  "class" : "Serial"
}
This class allows use of the built-in USARTs

Methods may be called on the USB, Serial1, Serial2, Serial3, Serial4, Serial5 and Serial6 objects. While different processors provide different numbers of USARTs, you can always rely on at least Serial1 and Serial2
 */
/*JSON{
  "type" : "event",
  "class" : "Serial",
  "name" : "data",
  "params" : [
    ["data","JsVar","A string containing one or more characters of received data"]
  ]
}
The `data` event is called when data is received. If a handler is defined with `X.on('data', function(data) { ... })` then it will be called, otherwise data will be stored in an internal buffer, where it can be retrieved with `X.read()`
 */

/*JSON{
  "type" : "event",
  "class" : "Serial",
  "name" : "framing"
}
The `framing` event is called when there was activity on the input to the UART
but the `STOP` bit wasn't in the correct place. This is either because there
was noise on the line, or the line has been pulled to 0 for a long period
of time.

**Note:** Even though there was an error, the byte will still be received and
passed to the `data` handler.
 */
/*JSON{
  "type" : "event",
  "class" : "Serial",
  "name" : "parity"
}
The `parity` event is called when the UART was configured with a parity bit,
and this doesn't match the bits that have actually been received.

**Note:** Even though there was an error, the byte will still be received and
passed to the `data` handler.
 */
// this is created in jsiIdle based on EV_SERIALx_STATUS ecents

/*JSON{
  "type" : "staticmethod",
  "class" : "Serial",
  "name" : "find",
  "generate_full" : "jshGetDeviceObjectFor(JSH_USART1, JSH_USARTMAX, pin)",
  "params" : [
    ["pin","pin","A pin to search with"]
  ],
  "return" : ["JsVar","An object of type `Serial`, or `undefined` if one couldn't be found."]
}
Try and find a USART (Serial) hardware device that will work on this pin (eg. `Serial1`)

May return undefined if no device can be found.
*/


/*JSON{
  "type" : "object",
  "name" : "USB",
  "instanceof" : "Serial",
  "#ifdef" : "USB"
}
The USB Serial port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial1",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=1"
}
The first Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial2",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=2"
}
The second Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial3",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=3"
}
The third Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial4",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=4"
}
The fourth Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial5",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=5"
}
The fifth Serial (USART) port
 */
/*JSON{
  "type" : "object",
  "name" : "Serial6",
  "instanceof" : "Serial",
  "#if" : "USART_COUNT>=6"
}
The sixth Serial (USART) port
 */

/*JSON{
  "type" : "object",
  "name" : "LoopbackA",
  "instanceof" : "Serial"
}
A loopback serial device. Data sent to LoopbackA comes out of LoopbackB and vice versa
 */
/*JSON{
  "type" : "object",
  "name" : "LoopbackB",
  "instanceof" : "Serial"
}
A loopback serial device. Data sent to LoopbackA comes out of LoopbackB and vice versa
 */
/*JSON{
  "type" : "object",
  "name" : "Telnet",
  "instanceof" : "Serial",
  "#if" : "defined(USE_TELNET)"
}
A telnet serial device that mapps to the built-in telnet console server (devices that have
built-in wifi only).
 */



{'fraction_non_alphanumeric': 0.18021371112978748, 'fraction_numerical': 0.007443870812822668, 'mean_word_length': 3.1258048538880634, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3351176', 'n_tokens_mistral': 2792, 'n_tokens_neox': 2749, 'n_words': 1048}