Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7736939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:52:20+00:00 2026-06-01T07:52:20+00:00

I am trying to create a NodeJS library that allows usage of the BeagleBone’s

  • 0

I am trying to create a NodeJS library that allows usage of the BeagleBone’s serial (uart) ports. Some of the pins are muxed so some configuration bits have to be written to two files. Here is my function that writes the configuration bits to enable the uart:

var setMuxForUart = function (uart, next) {
    var txFd, rxFd;
    var txBuf = new Buffer(uart.muxTx.config, 'ascii');
    var rxBuf = new Buffer(uart.muxRx.config, 'ascii');
    var txBytesWritten, rxBytesWritten;

    console.log ("Configuring UART MUX for " + uart.path);

    txFd = fs.openSync (MUX_PATH + uart.muxTx.path, 'w');
    rxFd = fs.openSync (MUX_PATH + uart.muxRx.path, 'w');

    if (txFd && rxFd) {
        try {
            txBytesWritten = fs.writeSync (txFd, txBuf, 0, txBuf.length, 0);
        }
        catch (e) {
            fs.closeSync (txFd);
            fs.closeSync (rxFd);
            console.log ('Error Writing to file: '+ MUX_PATH + uart.muxTx.path + ' | ' + util.inspect (e));            
            return;
        }

        try {
            rxBytesWritten = fs.writeSync (rxFd, rxBuf, 0, rxBuf.length, 0);
        }
        catch (e) {
            fs.closeSync (txFd);
            fs.closeSync (rxFd);
            console.log ('Error Writing to file: ' + MUX_PATH + uart.muxRx.path + ' | ' + util.inspect(e));            
            return;
        }

        fs.closeSync (txFd);
        fs.closeSync (rxFd);

        if (txBytesWritten && rxBytesWritten) {
            console.log ("Uart MUX finished configuration");
            next ();
        }
        else {
            console.log ("An error occured writing to the UART MUX.");
        }
    }
    else {
        console.log ("An error occured while opening the UART MUX files.");
    }
};

Here is the file containing this funcion.
Here is the output from running this function:

root@beaglebone:~/workspace/BonescriptSerial# node BonescriptSerial.js
The "sys" module is now called "util". It should have a similar interface.
Opening Serial Port for: /dev/ttyO1
Configuring UART MUX for /dev/ttyO1
Error Writing to file: /sys/kernel/debug/omap_mux/uart1_txd | { [Error: UNKNOWN, unknown error] errno: -1, code: 'UNKNOWN', syscall: 'write' }

I have verified that the correct output is written to test files, I have tried numerous mode parameters (‘0777’ doesn’t matter), I have tried this with the sync and async functions to no avail, and I have also tried, successfully, writing to these files in python. If you have any ideas that would help solve this problem I would be very grateful.

Here is a github repo of the project, its in its infancy right now so there isn’t alot of documentation. The python version is in the repo as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:52:21+00:00Added an answer on June 1, 2026 at 7:52 am

    Thanks to Ben Noordhuis on the NodeJS google group I was pointed to the following issue that was causing the problem. The device driver that I was trying to write to apparently doesn’t accept arbitrary seek writes, so in order to get around that I needed to trick NodeJS into using write instead of pwrite. The trick is to tell the write command to start writing at -1 instead of 0.

    fs.writeSync (txFd, txBuf, 0, txBuf.length, -1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create my first iPhone app that would play back audio. When I
hi I'm trying create chat using node.js I see example in http://chat.nodejs.org/ I have
I'm trying create a ASMX webservice that can perform a HTTP GET request. I
I am trying to create an HQL query that will filter a tree based
I am trying to create a post-receive hook in Nodejs to update my server
I am trying to build some utility to create document model from a string
I'm trying to create a JTree in which some nodes are compound objects containing
I'm trying to create a TreeView which allows the user to rename the nodes
I am trying to create a tree from a source that provides: the 2
I'm trying to create a multiplayer game with NodeJS and I want to synchronize

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.