NXT-PYTHON.CONF(5)

πŸ“¦
version 3.5.1 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ‘‘ nxt-python.conf β€” the NXT-Python manual, section 5 πŸ’…

okay bestie, so this is the page for nxt-python.conf from the NXT-Python docs. sit down, get a snack, we're doing config files πŸ“


✨ NAME ✨

nxt-python.conf β€” the NXT-Python configuration file. that's it, that's the name. iconic. πŸ’–


🌸 DESCRIPTION 🌸

so like. the NXT-Python config files let you define the NXT bricks you want to connect to, so you don't have to keep passing the same argument to every single script like a peasant. periodt. ✨

you can drop a .nxt-python.conf in your home directory, or in the current directory. you can also explicitly hand a config file name to the script or function you're invoking. your call, bestie, all three work. 🫢


πŸŽ€ FORMAT πŸŽ€

the vibe here is INI-style. it's made of several sections, and a section gets introduced by its name sitting in square brackets on its own line. each section holds a bunch of key/value pairs, and the key and the value are separated by an equal sign (=). very demure, very simple. πŸ’…

config can also have comments, and a comment starts with a # character.

when you're out here looking for a brick, you can ask NXT-Python to use a specific section, or [default] if you didn't specify one. if the section is missing, or if a value is missing, then the [DEFAULT] section is used as the fallback β€” note the uppercase, bestie, that part is not a typo, it's literally [DEFAULT]. πŸ™ˆ

here's everything you can define:

  • backends β€” the space separated list of backends to use when finding and connecting to the brick. when you don't specify it, a default list of backends gets used:
    • devfile <#module-nxt.backend.devfile> if filename is given,
    • socket <#module-nxt.backend.socket> if server_host or server_port is given,
    • usb <#module-nxt.backend.usb> and,
    • bluetooth <#module-nxt.backend.bluetooth>.
  • name β€” the brick name, used to find the brick (for example: NXT). you can configure the brick name using the NXT brick menus. 🧚
  • host β€” the Bluetooth address used to find the brick (for example: 00:16:53:01:02:03). when you're using the Bluetooth backend, this lets you connect directly without having to scan around to find the brick. for other backends, it can be used to select the right brick when several bricks turn up. ✨

you can find the address in the "Settings" menu, under the "NXT Version" screen β€” it's the last line, labeled "ID". add the colon to separate each pair of digits. (yes, you have to add the colons yourself. the brick is not gonna do it for you. 😭)

  • server_host β€” server address or name (example: 192.168.1.3, or localhost).

this one is used by the socket backend.

the server is provided by the nxt-server(1) command.

  • server_port β€” server connection port (default: 2727).

this is used by the socket backend.

the server is provided by the nxt-server(1) command.

  • filename β€” device file name (default is platform specific).

this is used by the devfile <#module-nxt.backend.devfile> backend to locate the RFCOMM device file.

please see the NXT-Python documentation for more details on how to use this. πŸ“š

  • Other values β€” other values are passed as-is to backends. no notes, they just go straight through. πŸ’Œ

πŸ”₯ EXAMPLE πŸ”₯

say you've got this config file:

[DEFAULT]
# Defines a fallback for every configuration name.
backends = usb

[default]
# My default NXT, sitting on my desk.
host = 00:16:53:01:02:03
name = NXT

[lab]
# When working at the lab, use my second NXT.
name = NXT2

[robot]
# Use Bluetooth for my third NXT, which is embedded in a robot, but try USB
# first as this is faster.
backends = usb bluetooth
host = 00:16:53:aa:bb:cc
name = ROBOT

when you're on the command line, NXT-Python connects to my default NXT if I don't give more options:

$ nxt-test
Finding brick...
NXT brick name: NXT
...

and I can request to connect to my robot NXT brick like this:

$ nxt-test --config robot
Finding brick...
NXT brick name: ROBOT
...

or when I'm using a script:

import nxt.locator
b = nxt.locator.find(config="robot")

telling, honestly. πŸ’…


πŸ“ FILES πŸ“

  • $HOME/.nxt-python.conf β€” per user configuration file.
  • .nxt-python.conf β€” configuration file in current directory.

πŸ‘€ SEE ALSO πŸ‘€


🫢 Author 🫢

this program is part of NXT-Python, which is currently maintained by Nicolas Schodet. thank you for your service king πŸ‘‘


2021-2025, Nicolas Schodet


and that's the whole page bestie!! version 3.5.1, dated Jan 26, 2026 β€” go forth and configure your bricks, you're gonna slay πŸ’…βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from