Ok so success in this whole monome setup script, I can execute systemctl start serialoscd with no errors! 🙂 Thank you so much!! Now I just need to figure out how to actually use this in C++ with the Bela, I have no idea honestly and I don't think the plain OSC examples really help me here? I am following this thread but it is a bit hard for me to understand and even at the end the OP doesn't seem to quite get it correctly: https://forum.bela.io/d/863-monome-grid-osc-bela/3

Sorry I am not really an engineer but more an artist hence all the simple questions, so I have a bit of difficulty with this and honestly was surprised that using monome wasn't so common or well documented with bela! I guess not enough people trying this yet? I will keep trying out things but I'm a bit lost for where to go from here...

    well my understanding is still the same as it was here:

    giuliomoro I know nothing about it, but I would guess that serialoscd is a bridge between OSC and the monome: my guess is that it receives OSC messages from the user application and passes them over to the monome over serial, and also receives serial from the monome and passes it on as OSC to the user application. So, I guess it has to stay open throughout for the program to work!

    I guess you now need to send OSC to serialoscd and receive OSC from it, using the OscSender and OscReceiver classes . This can be done using the Communication/OSC example as a starting point. That example relies on bi-directional communication with a node server, but ultimately you only need to send and receive (without the more complex handshake logic implemented in there).

    As to WHAT messages to send/receive, I have no idea, that would be in the monome documentation, I imagine? As to WHERE to send the messages (what port), that's hopefully in the serialosc documentation. Note that there will be nothing here that is Bela-specific, so you can probably find better support in specialised Monome forums.
    One thing that emerges from the README of serialosc is that you need to plugin the monome for the process to daemonise and do something useful. This may mean that in /lib/systemd/system/serialoscd.service it should be Type=forking as it was originally, instead of Type=simple as I changed it. I cannot test this because I don't have a monome, but you can. Make sure you look at the output of journalctl -f -n 50 -u serialoscd to see if anything useful is printed when the Monome is connected.

    a year later

    ndivuyo @guiliomoror Greetings! I'm getting along fairly well (for my needs at least!) with Bela Salt C++ programming. I'm thinking about buying a Monome Grid to use it to control the Bela Salt. What are the chances of this connectivity working reasonably smoothly?

    The above setup should work reliably, but I don't have a Monome so I couldn't try it out. @padenot may also be able to say something about how it worked for him. Because of how the BBG + Bela cape are mounted in Salt, you will need to solder some wires to the back of your BeagleBone to break out the UART signals.

    I confirm that plugging a monome device (arc or grid, I tested both) on a Bela just works, nothing special to report, just like any Linux computer. I've been using quite a few packages from different languages to test things out a few years back before writing mine in Rust, also nothing to report, everything just worked, even when stress testing it.

    I've only be using the regular Bela, not the mini, I don't know if we should expect anything different? Maybe it has less available power output to drive the monome or something?

      padenot I've only be using the regular Bela, not the mini, I don't know if we should expect anything different? Maybe it has less available power output to drive the monome or something?

      no should be the same. Which reminds me that the serial connection is actually virtual via USB, so

      you will need to solder some wires to the back of your BeagleBone to break out the UART signals.

      doesn't apply: if you have Salt+ along Salt, you have the USB host port right at the front, otherwise you can still plug it in onto the BBG's USB host port inside the rack.

        4 months later

        Hi giuliomoro Greetings! So, I finally got a Monome Grid delivered and installed enough on my Bela Salt so that #include <serialosc_helpers/SerialOsc.h> "works".

        However, I'm now trying to get something of https://github.com/daniel-bytes/serialosc_example/blob/master/serialosc_example/serialosc_example.cpp to work in my code - but I'm not sure what files I should put where on the Bela (and anything else I should do) in order to get the sample code working.

        Any tips would be gratefully received!

        Is serialosc built as a (shared or static) library? If yes, you'll need to set LDFLAGS and CPPFLAGS accordingly for the Bela project so that libserialosc is linked in and the appropriate -L and -I paths are set. You mention you can already include the header file appropriately, is that achieved by placing the source files for libserialosc in the project folder?

        24 days later

        Hi

        First a bit of eye candy :-)

        alt text

        OK, so I thought I would sort of start from scratch on my non Salt Bela and try and install serialosc again. I've probably made previous attempts on this device so its not a virgin try. (I might flash a fresh image soon)

        In the mean time, here's what I did.

        On the Bela terminal, I ran the contents of: https://monome.org/docs/serialosc/raspbian/

        And this went smoothly! At the end of the process I could enter serialoscd and it returned without error.

        Now, my next step was to try and test the grid with the Bela somehow.

        For this I thought I would and try and include SerialOsc.h from https://github.com/daniel-bytes/serialosc_example.git into my project.

        I wasn't really sure how I should to this but a ssh'd to the Bela again and git cloned serialosc_example.git into my Bela/projects/SimonSaysSeeq folder. Then I tried to build my project from the Bela IDE. I got some errors e.g.

        In file serialosc_example/serialosc_example/osckpack/ip/posix/NetworkingUtils.cpp: 'ip/NetworkingUtils.h' file not found column: 10, line: 37 -

        but I think I worked around those by adding some sym links.

        Then my project built with the line:
        #include <serialosc_example/serialosc_example/SerialOsc.h>
        - but then the Bela was unresponsive (both with and without the monome grids attached.

        Do you have any pointers for me on how to test serialosc is working? I'm kind of C++ newbi so I may be barking up several wrong trees!

        Happy to flash a fresh image etc.

        cheers, Simon

        p.s. Might it make sense to build in serialosc support if it enables devices such as grid etc?

          simonredfern In file serialosc_example/serialosc_example/osckpack/ip/posix/NetworkingUtils.cpp: 'ip/NetworkingUtils.h' file not found column: 10, line: 37 -

          that has two reasons: the file says:

          #include "ip/NetworkingUtils.h"

          which would normally semantically mean that there is an ip/ folder included in the current folder which contains a file NetworkingUtils.h (i.e.: in serialosc_example/osckpack/ip/posix/ip/NetworkingUtils.h). However, the file is in serialosc_example/osckpack/ip/NetworkingUtils.h, so it is not found. You could modify the path so that it goes back up one folder, i.e.: #include "../NetworkingUtils.h"), or - better (because it addresses the same issue with other files (if any)) - adding proper include paths to the Make parameters entry in the project settings : CPPFLAGS=-I serialosc_example/serialosc_example/osckpack.

          HOWEVER, you won't be able to build this project through the IDE as it is because it will try to build all .cpp files in the project but the files in the win32 folder include some Windows-specific header files, so you will at least need to delete that folder.

          I can build serialosc_example by placing in serialosc_example/serialosc_example the following file called Makefile

          CPPFLAGS = -Iosckpack -pthread -Wno-psabi
          CC=$(CXX) # for the linker
          LDLIBS=-lpthread
          
          OBJS:= \
          ./SerialOsc.o \
          ./osckpack/ip/IpEndpointName.o \
          ./osckpack/ip/posix/UdpSocket.o \
          ./osckpack/ip/posix/NetworkingUtils.o \
          ./osckpack/osc/OscPrintReceivedElements.o \
          ./osckpack/osc/OscOutboundPacketStream.o \
          ./osckpack/osc/OscReceivedElements.o \
          ./osckpack/osc/OscTypes.o \
          ./serialosc_example.o
          
          serialosc_example: $(OBJS)

          then you can cd into that directory (NOT via the Bela IDE) and type make to build it and ./serialosc_example to run it. Play around with it a bit.

          Now that you have the program building, what do you want to do it? How do you want to integrate it with a Bela program? To create a Bela program that will build through the IDE without need for extra Make parameters, you should organise the files as follows:

          projects/oscserial_bela/SerialOsc.h
          projects/oscserial_bela/UdpSocket.cpp
          projects/oscserial_bela/NetworkingUtils.cpp
          projects/oscserial_bela/SerialOsc.cpp
          projects/oscserial_bela/MessageMappingOscPacketListener.h
          projects/oscserial_bela/MonomeDevice.h
          projects/oscserial_bela/ip/IpEndpointName.h
          projects/oscserial_bela/ip/TimerListener.h
          projects/oscserial_bela/ip/NetworkingUtils.h
          projects/oscserial_bela/ip/UdpSocket.h
          projects/oscserial_bela/ip/IpEndpointName.cpp
          projects/oscserial_bela/ip/PacketListener.h
          projects/oscserial_bela/osc/OscPrintReceivedElements.cpp
          projects/oscserial_bela/osc/OscException.h
          projects/oscserial_bela/osc/OscOutboundPacketStream.cpp
          projects/oscserial_bela/osc/OscHostEndianness.h
          projects/oscserial_bela/osc/OscReceivedElements.cpp
          projects/oscserial_bela/osc/OscTypes.h
          projects/oscserial_bela/osc/OscReceivedElements.h
          projects/oscserial_bela/osc/OscPrintReceivedElements.h
          projects/oscserial_bela/osc/OscOutboundPacketStream.h
          projects/oscserial_bela/osc/OscTypes.cpp
          projects/oscserial_bela/osc/OscPacketListener.h
          projects/oscserial_bela/serialosc_example.cpp

          note that running this project from the IDE you won't be able to interact with it via the keyboard because the console at the bottom is not interactive.

          Anyhow, once this builds in the IDE, you can add a render.cpp (or add its contents to serialosc_example.cpp) and (IMPORTANT) rename the main() function which is in that file at the moment to something else.

            4 months later

            Hi future travelers. I have also got the grid working although it took me a bit. I'm going to leave some notes here in case it might be useful.

            This script is a total success for me: https://github.com/giuliomoro/bela-utils/blob/master/bela-setup-monome.sh (thank you @giuliomoro and @padenot !!)

            You also need to generate a monome config file. You can generate this config file by following these instructions. Just make sure that you can use those instructions to generate the file in ~/.config/serialosc/.

            Once you have the config file, you need to change one line in the /lib/systemd/system/serialoscd.service to use it:

            ExecStart=/usr/local/bin/serialoscd -c ~/.config/serialosc/

            That will make sure that it uses the config you generated and serialoscd doesn't switch ports everytime the Bela turns on.

            Then

            systemctl daemon-reload
            systemctl restart serialoscd

            will get it going.

            Using monome in code is pretty easy. Here's basically what I did in render.cpp(full code: https://github.com/schollz/palms/blob/53a85b62d11be26054f162b30342bb01b6c967e4/render.cpp#L12):

            ...
            #include <monome.h>
            
            // monome
            monome_t* monome;
            unsigned int grid[16][16] = {[0 ... 15][0 ... 15] = 0};
            #define MONOME_DEVICE "osc.udp://127.0.0.1:14656/monome"
            
            void handle_press(const monome_event_t* e, void* data) {
                unsigned int x, y;
            
                x = e->grid.x;
                y = e->grid.y;
            
                /* toggle the button */
                grid[x][y] = !grid[x][y];
                monome_led_set(e->monome, x, y, grid[x][y]);
            }
            
            static void monome_loop(void*) { // monome_event_loop(monome);
                while (!Bela_stopRequested()) {
                    monome_event_handle_next(monome);
                }
                monome_close(monome);
            }
            
            
            
            bool setup(BelaContext* context, void* userData) {
                /* open the monome device */
                if (!(monome = monome_open(MONOME_DEVICE, "8000")))
                    return -1;
                monome_led_all(monome, 0);
                /* register our button press callback */
                monome_register_handler(monome, MONOME_BUTTON_DOWN, handle_press, NULL);
                Bela_runAuxiliaryTask(monome_loop);
                ...

            One important note is that the port you use for #define MONOME_DEVICE "osc.udp://127.0.0.1:14656/monome" needs to have the port (mine is 14656) match what is in your config file. You can find your port by running cat ~/.config/serialosc/*, for example it gives me:

            server {                  
              port = 14656            
            }                         
            application {             
              osc_prefix = "/monome"  
              host = "127.0.0.1"      
              port = 8000             
            }                         
            device {                  
              rotation = 0            
            }                         

            So you can see that I use port 14656 for everything and define that in my render.cpp

              Thanks for the feedback.

              infinitedigits This script is a total success for me

              Great. It actually seems that there are minor changes needed to it, e.g.:

              infinitedigits Once you have the config file, you need to change one line in the /lib/systemd/system/serialoscd.service to use it:

              ExecStart=/usr/local/bin/serialoscd -c ~/.config/serialosc/

              could you make a pull request to my repo to include this change?

              2 years later

              Please let me know if I need to move this question to a new post, though this post has helped me nearly get up and running.I have a Bela with latest 0.3.8 image and looking to get serialosc installed.

              After some time getting apt-get update to work (couldn't find Release info or something) I finally installed the lib tools. Found somewhere that need to run echo "deb http://archive.debian.org/debian stretch main contrib non-free" > /etc/apt/sources.list.

              I clone/build/install the libmonome.git however for serialosc. when configuring it seems to be successful (though fmemopen and reallocarray are checked as 'no' and windows.h is not found). When I run ./waf I get the following error
              [ 1/23] Compiling src/common/util.c
              gcc: error: unrecognized command line option '-std=c17'; did you mean '-std=c11'?

              Waf: Leaving directory `/root/serialosc/build'
              Build failed
              -> task in 'serialosc-common' failed with exit status 1 (run with -v to display more information)

              Any ideas?

              It seems that this commit increased the C standard level from C99 to C17 for the purpose of supporting anonymous unions in accordance to the updated standard instead of using the compiler-specific __extension__ keyword. However, it looks like this improvement to the language took place in the transition from C99 to C11 (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2244.htm), so they could have as well specified C11 instead of C17. This was a pretty recent change and it doesn't look like any new code has been added since then that would rely on C17. For all of these reasons, I think it is safe to lower the requirement to C11 which is the latest C revision supported by gcc on the latest Bela version.

              Apply this patch and you should be able to build:

              diff --git a/wscript b/wscript
              index 659328c..cdd25ab 100644
              --- a/wscript
              +++ b/wscript
              @@ -281,9 +281,9 @@ def configure(conf):
              
              
                      if conf.options.enable_debug:
              -               conf.env.append_unique("CFLAGS", ["-std=c17",  "-Wall", "-g", "-Og"])
              +               conf.env.append_unique("CFLAGS", ["-std=c11",  "-Wall", "-g", "-Og"])
                      else:
              -               conf.env.append_unique("CFLAGS", ["-std=c17", "-Wall", "-Werror", "-O2"])
              +               conf.env.append_unique("CFLAGS", ["-std=c11", "-Wall", "-Werror", "-O2"])
              
              
                      if conf.env.CC_NAME in ["gcc", "clang"]:

              (i.e.: replace c17 with c11 in wscript). You'll have to rm -rf build and ./waf configure again after this for the changes to be picked up.

              Thanks! Some success. I just changed wscript file directly from c17 to c11 and it now seems to build and install correctly.

              I run the journalctl command and it reports following when plugging in

              'Nov 12 05:47:49 bela serialoscd[17492]: serialosc [m1001113]: connected, server running on port 19852'
              when unplugging it reports
              'Nov 12 05:48:09 bela serialoscd[17492]: serialosc [m1001113]: couldn't write config :(
              Nov 12 05:48:09 bela serialoscd[17492]: serialosc [m1001113]: disconnected, exiting'

              Not being able to write config is a problem now as see I need to edit this file to fix port address. I see the ~/.config hidden folder but clearly no config is written there
              if I run serialoscd it has made a serialosc folder under config but unplugging device does not generate the appropriate .conf file

              Im sure there's miles to go still to get a monome max script running on the Bela but this is the first hurdle - thank you!

              I was also trying to install this with the max/rnbo tutorial in the monome package, even after I update apt it could not find the serialosc package when typing sudo apt-get install serialosc.

              Anyway, up and running now with serialosc starting at boot - a good start

              I have looked into this and I am unsure I can test this any further without having a monome myself. Try adding this printf statement so we know what path it's trying to open:

              diff --git a/src/serialosc-device/config.c b/src/serialosc-device/config.c
              index b6fda47..d3a05fd 100644
              --- a/src/serialosc-device/config.c
              +++ b/src/serialosc-device/config.c
              @@ -135,6 +135,7 @@ sosc_config_write(const char *config_dir, const char *serial, sosc_state_t *stat
                              path = path_for_serial(sosc_get_default_config_dir(), serial);
                      }
              
              +       printf("FOPEN PATH %s\n", path);
                      if (!(f = fopen(path, "w"))) {
                              s_free(path);
                              return 1;

              Rebuild, restart, replug