| Config Files | Index |
The BrainStem® examples and application software all use simple text files for establishing settings that vary between platforms, specific computers, simulations, or remote relays of code. These config files are optional and allow default settings for these examples and applications to be changed without re-compiling the underlying code.
Settings
The settings in these files are completely up the the discretion of the application but there are often settings to determine how the program will connect and establish a link to hardware. In many applications and examples, additional or alternative settings are also available that are more application specific. These settings are detailed in the default .config files for those cases.
Location
The configuration files are all sought at the directory location where the application is run (current working directory). Most often this is in the aBinary directory of the acroname download directory structure... next to the executable files as a sibling.
| Note: | If you are savy enough to have created a path to your executables to allow them to be run from other locations than the aBinary directory then you are sophisticated enough to also realize that the config files can reside anywhere and are sought in the CWD. This means you can have alternative configurations, based on where you run the application or example from. |
Filename
These files can potentially have any name but the common convention is to take the application name, remove the leading "a" and lowercase the remainder. In this way the aConsole, aGP and aMoto applications have config files named "console.config, gp.config" and "moto.config". An example named "aFoo" would then have, by this convention, the configuration file name "foo.config". These names are case sensitive and commonly have a ".config" file extension.
| Note: | If you are not savy enough to realize that file extensions are hidden by some operating systems and configurations, you may not see the ".config" file extension on these file as part of the name. It may require some display settings or properties to reveal these actual file names. One of the most common mistakes is forgetting this and/or not seeing an additional (and incorrect) .txt extension in the configuration filename. |
Syntax
The config files are plain text files that can be created or edited with any plain text file editor (vi, emacs, Notepad, XCode, etc...) Each line is typically a setting name followed by an equal sign followed by the setting value. Any characters beyond and including a '#' character are considered a comment to the end of that line. Blank lines are ignored. Setting values can be simple text names, quoted strings, numbers, ip addresses, and boolean values. Below are some examples:
# a comment line followed by an allowable blank line text_setting1 = foo text_setting2 = "foo bar" number_setting = 23 hex_number_setting = 0x45 boolean_setting = true boolean_setting = false ip_address = 192.168.2.32 rgb = 0x446622 tweaker=45 # no need to crowd out spaces as they are ignored |
linktype
Probably the most important and general configuration is the linktype setting. This set of setting options is used by the basic BrainStem applications, many examples, and other command line tools, etc. This set of settings is used in the aStream_CreateFromSettings aIO library call to establish a link to a BrainStem whether in hardware or simulation. The acpStem C++ class uses this routine as well to establish the link.
There are current 3 main options for the linktype setting in configuration files: "serial" (default), "ip", and "usb". These names are relatively self explanatory. Below are three config files with an example of each linktype that shows the dependent settings for all three types:
# serial example with Windows defaults shown linktype = serial portname = COM1 baudrate = 9600 |
The first line "linktype = serial" is optional since serial is the default linktype setting. The second line is the portname which varies depending on your machine, operating system, and preferences.
On Windows, the portname is typically a COM port specifciation like COM1, COM2, etc... When using a usb-to-serial adapter, you may need to inspect the device properties to learn which COM port is being used.
On the Mac OS X and Linux, the portname typically refers to a device in your /dev directory. Typing "ls /dev" in a terminal will give you an idea of what is present. The serial port names typically start with tty and have more added on to specify the port. Linux often uses ttyS0, ttyS1, etc. Mac OS X uses a name that the driver provides and often includes the serial number at the end such as "tty.usbserial-A3232325". The /dev path is assumed on both platforms so you only need to type "portname = ttyUSB0" or whatever is appropriate for your circumstance. Also, make sure you have read/write permission on the unix device you are trying to use.
The baudrate is the serial baudrate used and defaults to 9600. The current available baudrates include 2400, 9600, 14400, 19200, 38400, 57600, and 115200. These may change or be exteneded but you can generally use these in most all cases... provided what you are linking to is configured to use that same matching baudrate.
# TCP/IP example showing link settings to 192.168.1.4:8000 linktype = ip ip_address = 192.168.1.4 ip_port = 8000 |
The first line "linktype = ip" specifies a TCP/IP link should be used. This assumes the network is up and working, firewalls allow traffic, and you an successfully ping/connect with the remote hardware, relay, simulation, or other system serving the TCP/IP socket you want to connect with.
The ip_address setting specifies the (currently IPv4) TCP/IP address where the server is available to access. The default for this setting is the machine you are running on so if you are connecting locally, you need not specify this setting.
The port number specifies the TCP/IP port to use for the client connection to the server. This port is, by convention above the first 1024 reserved ports but any can be used. The default for the port when using "linktype = ip" is 8000.
# USB example showing link to BrainStem serial number 254 linktype = usb usb_id = 254 |
| Note: | Don't be confused by the linktype if you are using a usb-to-serial adapter. Since that adapter resolves in your computer to a virtual serial port, you would still use linktype = serial, even though the adapter plugs in to USB. The linktype = usb is for a BrainStem module that has a native USB interface. |
The setting of "linktype = usb" means you want a link from the software to a BrainStem module with native USB support. In that case, the module will have a serial number that uniquely identifies that module. This serial number is the value used for the usb_id setting to connect to that module. There is no reliance on where the device is plugged or in what order multiple devices are plugged in.