NEQTO Docs
  • Languages iconEnglish
    • 日本語
  • Docs
  • API
  • FAQ

›neqto.js

Getting Started

  • NEQTO Hello World!
  • Tutorial Step 1. NEQTO Console Setting
  • Tutorial Step 2. Device Settings & Launching Service (NEQTO Bridge)
  • Tutorial Step 2. Device Settings & Launching Service (STM32 Discovery)
  • Tutorial Step 2. Device Settings & Launching Service (SPRESENSE)
  • Tutorial Step 3. Application development using scripts

NEQTO

  • NEQTO Account Registration
  • Sub-accounts
  • API Usage
  • NEQTO Engine Firmware List
  • Support Guidelines
  • For safe and secure use of the NEQTO products
  • Vulnerability Disclosure Policy

NEQTO Console

  • Introduction
  • Fundamentals
  • Administrative Actions
  • Device Management
  • Linux-based Device Management
  • Batch Registration
  • Scripts
  • Actions and Contacts
  • View Data from the Console
  • NEQTO Apps

    • About NEQTO Apps
    • NEQTO Infinitypool
    • NEQTO Insights
    • NEQTO Custodia
    • NEQTO Flow
  • Machine Driver
  • Recommended Browsers
  • Billing Information

SPRESENSE

    Hardware Specifications

    • 01. About Spresense

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. Spresense Wi-Fi Initial Setup
    • 04. Spresense LTE-M Initial Setup
    • 05. Debug Log Acquisition
    • 06. System LED Indications
    • 07. Event Messages
    • 08. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. GPIO
    • 12. UART
    • 13. SPI
    • 14. I2C
    • 15. ADC
    • 16. GNSS
    • 17. Camera
    • 18. Utils
    • 19. nqSpresense
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte

STM32 Discovery

    Hardware Specifications

    • 01. About STM32 Discovery Kit (B-L4S5I-IOT01A)

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. STM32 Discovery Wi-Fi Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 18. Utils
    • 19. nqDiscovery
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi

NEQTO Bridge

    Hardware Specifications

    • 01. NEQTO Bridge Module
    • 02. NEQTO Bridge Wi-Fi Module
    • 03. NEQTO Bridge LTE-1 Module
    • 04. NEQTO Bridge LTE-M/NB Module
    • 05. NEQTO Bridge IO Board
    • 06. NEQTO Bridge Digital IO Board
    • 07. NEQTO Bridge Connector Board

    Software Specifications

    • 01. Operational Flow
    • 02. NEQTO Bridge Wi-Fi Module Initial Setup
    • 03. NEQTO Bridge LTE Module Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 17. BLE
    • 18. Utils
    • 19. nqBridge
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte
    • 25. nqLAN
    • 26. nqEx

Linux-based device

    Software Specifications

    • 01. System Requirements
    • 02. Installation
    • 03. Software Configurations
    • 04. Operational Flow
    • 05. Debug Log Acquisition
    • 06. Event Messages
    • 07. Updating Software

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. RTC
    • 10. UNIXSocket
    • 11. FileSystem
    • 12. SubProcess
    • 13. SubTask
    • 14. Queue
    • 15. Utils
    • 16. nqLinux
    • 17. nqService
    • 18. nqMqtt
    • 19. nqFOTA
    • 20. nqLAN

neqto.js Libraries

  • About neqto.js Libraries
  • UART

    • GM65 Barcode Reader
    • SRF Ultrasonic Range Finder - Serial Mode

    I2C

    • HTS221 v2 Temperature and Humidity Sensor
    • LIS2DW12 v2 Accelerometer
    • SRF Ultrasonic Range Finder - I2C Mode
    • [Archive] HTS221 Temperature and Humidity Sensor
    • [Archive] LIS2DW12 Accelerometer

    Utils

    • RTC Alarm Synchronized Scheduler

    Integration

    • AWS S3 v2
    • AWS IoT Core v2
    • Azure IoT v2
    • [Archive] GCP IoT Core
    • [Archive] AWS S3
    • [Archive] AWS IoT Core

neqto.js Snippets

  • About neqto.js Snippets
  • DataDog
  • Dropbox
  • Google Sheets
  • InfluxDB
  • Oracle Cloud Object Storage
  • Salesforce
  • Splunk
  • Niagara
  • [Archive] SAP Cloud Platform Internet of Things

Release Notes

  • NEQTO Console Updates
  • NEQTO Firmware (Bridge Wi-Fi/LTE Module) Releases
  • NEQTO Firmware (STM32 Discovery Wi-Fi) Releases
  • NEQTO Firmware (Spresense Wi-Fi/LTE-M) Releases
  • NEQTO Engine for Linux Releases
  • neqto.js Libraries Releases

14. Queue

The queue object is a built-in object that provides data queue functionality.

Functional overview:

  • Provides FIFO queue functionality.
  • Supports arbitrary strings and arbitrary numbers as elements to be stored in the queue.

Limitations:

  • The number of queue instances that can be used simultaneously is 8.
  • This feature is an extension option exclusively for the NEQTO Engine for Linux.
    Depending on the queue size setting and the number of instances, system memory (RAM) will be consumed.



queue Global Object

Methods()/PropertiesSummaryVersionNote
queue.create()Creates a queue instance.00.02.00+



queue.create(size)

Creates a queue instance.

NameTypeM/OSummary                                   Note
sizenumbermandatorySpecify the queue size [KB].
Range: 1 - 512
If out of range, it will be rounded to the nearest valid value.
return{FIFO}-{FIFO} : Generated {FIFO}When an error occurs, an exception is raised.

About the number of elements that can be stored in a queue

The buffer allocated to the queue stores the element data without gaps. Therefore, if the element size is variable length, the number of elements that can be stored in the queue will increase or decrease. Consequently, the queue size is determined based on the expected maximum size of the elements and the minimum number of elements that must be stored.

The maximum data size consumed by a single element is "maximum arbitrary string size + 12 bytes".
Therefore, the required queue size is "maximum data size consumed by a single element × minimum number of elements that must be stored".



{FIFO}

Methods()/PropertiesSummaryVersionNote
.push()Adds an element to the FIFO queue.
.pop()Extracts an element from the FIFO queue.
.getCount()Gets the number of elements stored in the FIFO queue.
.reset()Initializes the FIFO queue.
.release()Releases the FIFO queue.



Details

.push(str[,num])

Adds an element to the FIFO queue.

NameTypeM/OSummary                                   Note
strstring, undefinedmandatoryArbitrary string
If undefined is specified, it will be treated as an empty string.
numnumberoptionalArbitrary number
The default value is 0.
returnboolean-true : Success
false : Failure
When an error occurs, an exception is raised.

.pop()

Extracts an element from the FIFO queue.

NameTypeM/OSummaryNote
return{Element}, null-{Element}: The oldest element is returned.
null: No elements

{Element}

NameTypeSummaryNote
.strstringArbitrary string
.numnumberArbitrary number

.getCount()

Gets the number of elements stored in the FIFO queue.

NameTypeM/OSummaryNote
returnnumber-The number of stored elements

.reset()

Initializes the FIFO queue.

NameTypeM/OSummaryNote
returnundefined--

.release()

Releases the FIFO queue.

NameTypeM/OSummaryNote
returnundefined--



Object Usage Examples

Sample 1

This is a sample of a basic FIFO queue.

var fifo = queue.create(4); //4KB

for(var i=0; i<10; i++) {
    var str = 'TestData' + i;
    var ret = fifo.push(str);
    if(ret == false) { //overflow
        print(`IN${i}: Full`);
    } else {
        print(`IN${i}: cnt=${fifo.getCount()}`);
    }
}

var cnt = 0;

while(1) {
    var obj = fifo.pop();
    if(obj) {
        print(`OUT${cnt++}: str=${obj['str']}, cnt=${fifo.getCount()}`);
    } else {
        print('Empty');
        break;
    }
}

fifo.release();

Sample 2

This is a sample that uses a FIFO queue to perform numerical calculations.

var fifo = queue.create(12); //12KB

for(var i=0; i<1000; i++) {
    var ret = fifo.push(undefined, i);
    if(!ret){ //overflow
        print(`IN${i}: Full`);
    } else {
        print(`IN${i}: cnt=${fifo.getCount()}`);
    }
}

var cnt = 0;
var total = 0;

while(1) {
    var obj = fifo.pop();
    if(obj) {
        print(`OUT${cnt++}: num=${obj['num']}, cnt=${fifo.getCount()}`);
        total += obj['num'];
    } else {
        print('Empty');
        break;
    }
}

print(`Sum of 0 to 999: ${total}`);

fifo.release();

Sample 3

This is a sample that utilizes a FIFO queue to construct a sequence branch processing.

var fifo = queue.create(1); //1KB

var seqName = [ //seq
    "init",     //0
    "push",     //1
    "check",    //2
    "exit"      //3
];
var seqTbl = [
    //seq, arg
    [ 0, "" ],
    [ 1, "abcdefg" ],
    [ 2, "" ],
    [ 3, "" ]
];

for(var i=0; i<seqTbl.length; i++) {
    var ret = fifo.push(seqTbl[i][1], seqTbl[i][0]);
    if(!ret) { //overflow
        print(`IN${i}: Full`);
    } else {
        print(`IN${i}: cnt=${fifo.getCount()}`);
    }
}

var act = true;
var tmp = '';

while(act) {
    obj = fifo.pop();
    if(obj) {
        var seq = obj['num'];
        var arg = obj['str'];
        print('seq:', seqName[seq], arg);
        switch(seq) {
            case 0: //init
                tmp = '';
                break;
            case 1: //push
                tmp = tmp + arg;
                break;
            case 2: //check
                print(tmp, tmp.length);
                break;
            case 3: //exit
                act = false;
                break;
            default:
                print('Unknown');
                break;
        }
    }
}

fifo.release();



Updated: 2025-01-29
← 13. SubTask15. Utils →
  • queue Global Object
    • queue.create(size)
  • {FIFO}
  • Details
    • .push(str[,num])
    • .pop()
    • {Element}
    • .getCount()
    • .reset()
    • .release()
  • Object Usage Examples
    • Sample 1
    • Sample 2
    • Sample 3
AboutNewsProductsFAQPrivacy PolicyVulnerability Disclosure Policy
NEQTO Console
IntroductionFundamentalsAdministrative ActionsDevice Management NEQTO Apps
NEQTO Bridge
NEQTO Bridge ModuleNEQTO Bridge Wi-Fi ModuleNEQTO Bridge LTE-1 ModuleError Logging Event Messages
API Documentation
API UsageGlobal APIRegional APIAPI Terms of Service
Jigsaw, Inc.
© 2025 JIG-SAW INC.