Skip to content

readFileSync Appears Un-synchronous or Fails on Raspberry Pi 3 #10621

@noncreature0714

Description

@noncreature0714

Situation:

I'm trying to capture my RPi3's mac addresses using synchronous file reading, getting information from my host system at `/sys/class/net/*/address`.

Action:

I have two branches at this repo: https://github.com/noncreature0714/gen-sys-id-node.git

Branch master is the asynchronous version, and works successfully.
Branch sync-test is synchronous, and is not working as expected - almost as if it never ran synchronously.

Results:

Output of 'master' (asynchronous) branch is:

ifs.eth0: "my correct eth0 mac address here"
ifs.wlan0: "my correct wlan0 mac address here"

Output of 'sync-test' branch is:

ifs.eth0: function String() { [native code]}
ifs.wlan0: function String() { [native code]}

Summary

The values where never assigned, almost like what happens when asynchronous operations occur after accessing variables. Additionally, the `console.log()` inside the functions never logs. Which leads me to consider the possibility that `readFileSync` may not be working at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions