OttoDIY / blockly

Otto Blockly; a fully integrated graphical programming for any type of Arduino projects, including robots, ready to install in your computer, it works offline and also online
https://www.ottodiy.com/software
GNU General Public License v2.0
118 stars 81 forks source link

Linux, Ubuntu, Raspbian (Raspberry Pi OS) installer #38

Closed cparrapa closed 3 years ago

cparrapa commented 4 years ago

Separated from #9 as suggested by @mxochicale

cparrapa commented 4 years ago

Hola @mxochicale

Nuestro amigo @agomezgar ya hizo un gran progreso aquí https://github.com/agomezgar/masayloBlockly/tree/05e43fb3a85b9adc2c1ab78e9b46a361a9bdb510/linux

Lo puedes ensayar?

mxochicale commented 4 years ago

Wow, Gracias @cparrapa y @agomezgar :) Lo checo el pr'oximo fin de semana :)

gitaroktato commented 4 years ago

Hi @mxochicale, is someone looking at this? Is there any progress? Are there any manual steps available for experimenting?

mxochicale commented 4 years ago

Hi @gitaroktato

, is someone looking at this?

I am interested in this issue but only making little progress on my weekends.

Is there any progress? Are there any manual steps available for experimenting?

Antonio Gómez has made some progress here and waiting for some instructions stated here. Perhaps, if you don't want to wait, you can start having it a go :)

gitaroktato commented 4 years ago

@mxochicale after bumping serialport dependency version to 8.0.4 the build was successful, but when running the application with npm install I get a blank screen. Any guidance on how I can fix this?

P.S.: If this works, I can submit a pull request.

gitaroktato commented 4 years ago

It's not ready yet, but it's something. :+1:

Screenshot from 2020-09-07 21-52-22

mxochicale commented 4 years ago

Great progress @gitaroktato

It would be nice that you add explicit instructions on how you are building it in Ubuntu plus the version and architecture of your GNU/Linux distro. Perhaps, this might be one example for the readme file. I would be more than happy to help to review it and test it on my machines.

agomezgar commented 4 years ago

I'm deeply sorry. You're right. I must make some documentation tasks. Problem is, i'm a high school teacher in a country deeply affected by covid these data, and i'm too busy just now(please forgive my poor english). Your first problem: if you upgrade your electron versión, you must add webPreferences:{nodeIntegration:true} in every new BrowserWindow command used in the electronApp.js file

Written from my smartphone (not so smart).

El lun., 7 sept. 2020 22:49, Miguel Xochicale notifications@github.com escribió:

Great progress https://github.com/gitaroktato/blockly/commit/0e56fe0be2fba0c0d69a8289d6a27ccc5936902a @gitaroktato https://github.com/gitaroktato

It would be nice that you add explicit instructions on how you are building it in Ubuntu plus the version and architecture of your GNU/Linux distro. Perhaps, this might be one example https://github.com/fontainejp/blocklino/#how-to-use for the readme file. I would be more than happy to help to review it and test it on my machines.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OttoDIY/blockly/issues/38#issuecomment-688506738, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACULR565FDFNAGUGUMTHC4TSEVBN7ANCNFSM4OKVKKEQ .

gitaroktato commented 4 years ago

I'll just keep updating the issue, so someone can also take this further if I'm unable to. You can track the progress by comparing master to my personal branch: https://github.com/OttoDIY/blockly/compare/master...gitaroktato:linux_build

Runtime environment

Steps taken so far

Building the project First, build & compile everything

npm install

Next, run the electron app

npm start

Debugging the app Run the app in debug mode

npm run debug

Attach to the running process with VSCode

Also, you can bring up the developer console by hitting F8.

Update - 2020-09-08

The serial monitor functionality was not working. I suspect that somehow index.js was not loaded properly. When I build another blockly based project, the serial monitor window opens normally. The same is also true for the "Check the code" functionality.

This solved the issue: https://stackoverflow.com/a/55908510/8321787

Another problem was, that I had to add app.allowRendererProcessReuse = false to load a native serial library from the renderer.

Update - 2020-09-09

The serial library API changed, so tried to downgrade to an older version to see if it still compiles. This did not work, so I ended up changing the breaking methods from callback to Promise. I had to import Arduino and Python binaries for Linux from the another blockly based project and refer to those in every exec() command in index.js

Everything seems to work now if I run the project with npm start. I have to wait for my Otto builder kit to arrive to test this for real :wink:

image

Current issues

My branch is more like a POC. I totally suspect, that the changes are breaking Windows build, so I need to refactor my version and make the whole build multi-platform. Make it work, make it pretty.

I can't make a releasable package with npm run compiler because the directory structure is different. Have to introduce some kind-of configuration for these: image

gitaroktato commented 4 years ago

@agomezgar @mxochicale - could you please check out this branch and see if it works with the steps above? All you need to do to run the application is an npm install followed by an npm start.

I can work on fixing the compiler and deb64 goals in the meantime.

mxochicale commented 4 years ago

Great progress @gitaroktato

I have tried your linux_build branch in https://github.com/gitaroktato/blockly in my machine with Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic. I got the following error that might be related to some permissions. Any ideas on how to sort it out?

Screenshot from 2020-09-13 07-50-56

README

Additionally, perhaps you would like to create a README file in ~/compilation/dependencies/ where you can start adding the above instructions. I think such instructions are very important to allow other users to test your work. For example, you can add in that README file something like this:

## usage 
git clone https://github.com/gitaroktato/blockly
cd ~/blockly
git checkout linux_build 

## dependencies and requirements 
* You can use my README on how to setup a conda env
https://github.com/mxochicale/BlocklyDuino/tree/49afe53fbc62f06a5c342e334a13c6b46581246a/setup_arduino_web_server

* checking usb port 
ll /dev/serial/by-id/
624 lrwxrwxrwx 1 root root 13 Sep 13 07:37 usb-1a86_USB_Serial-if00-port0 -> ../../ttyUSB0

* Be more explicit in the installation of 
Node 10.22.0 # here some nice instructions https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04 
npm 6.14.6 # here some nice instructions  https://github.com/nvm-sh/nvm

Also the first time I run npm install I need to run `sudo chown -R $USER:$(id -gn $USER) /home/$USER/.config`
mxochicale commented 4 years ago

Thanks @agomezgar for such great effort and share your work

Slightly similar as above, and with the dependencies suggested by gitaroktato, I have tried your linux build in my machine with Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic by cloning https://github.com/agomezgar/blockly and I got the following error that might be related to some permissions. Any ideas on how to sort it out?

Screenshot from 2020-09-13 08-04-31

You might also like to create a README file as suggested above.

agomezgar commented 4 years ago

I could solve (or so I think) the serial monitor problem, @gitaroktato . New versions of serialmonitor don't admit functions anymore. I.e., this old code: sp.list(function(err,ports) { var nb_com = localStorage.getItem("nb_com"), menu_opt = portserie.getElementsByTagName('option') if(ports.length > nb_com){ ports.forEach(function(port){ if (port.vendorId){ var opt = document.createElement('option') opt.value = port.comName opt.text = port.comName portserie.appendChild(opt) localStorage.setItem("com",port.comName) } }) localStorage.setItem("nb_com",ports.length) localStorage.setItem("com",portserie.options[1].value) } if(ports.length < nb_com){ while(menu_opt[1]) { portserie.removeChild(menu_opt[1]) } localStorage.setItem("com","com") localStorage.setItem("nb_com",ports.length) } Must be changed for something like: sp.list().then(ports => { var nb_com = localStorage.getItem("nb_com"), menu_opt = portserie.getElementsByTagName('option') if(ports.length > nb_com){ ports.forEach(function(port){ if (port.vendorId){ var opt = document.createElement('option') opt.value = port.path opt.text = port.path portserie.appendChild(opt) localStorage.setItem("com",port.path) } }) localStorage.setItem("nb_com",ports.length) localStorage.setItem("com",portserie.options[1].value) } if(ports.length < nb_com){ while(menu_opt[1]) { portserie.removeChild(menu_opt[1]) } localStorage.setItem("com","com") localStorage.setItem("nb_com",ports.length) } }); You are right in other comment that you do, which is the different folder system related to Linux version. I solved it by creating a humble script that detects if it's the first time the application is being executed and then creating an auxiliary data folder into the home user directory, so we can avoid any permission problems. Summary: many changes are needed. I have a first working Linux version here, in my own github. You can download an AppImage (portable version) here SPAM I learned these things, in first place, analyzing @cparrapa work here and @fontainejp with blocklino. and secondly, creating my own graphical programming environment, MasayloBlockly, which allows you to program many types of robots as well as doing general programming jobs with Arduino.

agomezgar commented 4 years ago

Thanks @agomezgar for such great effort and share your work

Slightly similar as above, and with the dependencies suggested by gitaroktato, I have tried your linux build in my machine with Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic by cloning https://github.com/agomezgar/blockly and I got the following error that might be related to some permissions. Any ideas on how to sort it out?

Screenshot from 2020-09-13 08-04-31

You might also like to create a README file as suggested above.

It seems to me that the app can't communicate with your Arduino. What model are you using? It's a nano 168? Because these model is not adapted yet. I'm working on this issue.

agomezgar commented 4 years ago

First question, really, should be: have you programmed an Arduino the usual way before you have tested this app?. Because, as I think you know, some Linux OS give some permission problems related to the DIALOUT group. If so, try opening your shell and typing: sudo usermod -a -G dialout youruser where youruser is the user name you are running the program with.

mxochicale commented 4 years ago

First question, really, should be: have you programmed an Arduino the usual way before you have tested this app?. Because, as I think you know, some Linux OS give some permission problems related to the DIALOUT group. If so, try opening your shell and typing: sudo usermod -a -G dialout youruser where youruser is the user name you are running the program with.

Many thanks @agomezgar

Good news OttoDIY/blockly is now working on my Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic. I just need to chose Arduino Nano instead of "Arduino Nano (old bootloader)" Screenshot from 2020-09-13 08-30-10

Thanks for the hint on testing nano with arduino app. I did test nano with arduino app with Board: Arduino Nano; Processor: ATMega328P; Port:/dev/ttyUSB0. For the record, see the terminal output for the ttyUSB0 port

ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Sep 13 08:21 /dev/ttyUSB0

PS. I guess next step is to create a branch for linux_build in OttoDIY/blockly (to avoid conflict with others OS) where you can add a README with some instructions for the dependencies, usage, and installations steps. Happy to help with reviews and tests of such PR.

agomezgar commented 4 years ago

First question, really, should be: have you programmed an Arduino the usual way before you have tested this app?. Because, as I think you know, some Linux OS give some permission problems related to the DIALOUT group. If so, try opening your shell and typing: sudo usermod -a -G dialout youruser where youruser is the user name you are running the program with.

Many thanks @agomezgar

Good news OttoDIY/blockly is now working on my Ubuntu 18.04.3 LTS x64 - Linux kernel 5.3.0-53-generic. I just need to chose Arduino Nano instead of "Arduino Nano (old bootloader)" Screenshot from 2020-09-13 08-30-10

Thanks for the hint on testing nano with arduino app. I did test nano with arduino app with Board: Arduino Nano; Processor: ATMega328P; Port:/dev/ttyUSB0. For the record, see the terminal output for the ttyUSB0 port

ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Sep 13 08:21 /dev/ttyUSB0

PS. I guess next step is to create a branch for linux_build in OttoDIY/blockly (to avoid conflict with others OS) where you can add a README with some instructions for the dependencies, usage, and installations steps. Happy to help with reviews and tests of such PR.

Those are great news!. You know? You're the first one who test the program apart from me. I am really happy that it works for you. Your suggestions, on the other hand, are welcome, and I am working on it.

mxochicale commented 4 years ago

First question, really, should be: have you programmed an Arduino the usual way before you have tested this app?.

PS. I guess next step is to create a branch for linux_build in OttoDIY/blockly (to avoid conflict with others OS) where you can add a README with some instructions for the dependencies, usage, and installations steps. Happy to help with reviews and tests of such PR.

Those are great news!. You know? You're the first one who test the program apart from me. I am really happy that it works for you. Your suggestions, on the other hand, are welcome, and I am working on it.

Very happy to help. My suggestion is that you create a new branch called linux_build in your https://github.com/agomezgar/blockly and add detailed instructions for the linux_build and then you can create a new PR and ask for reviews to us. I am saying that because your https://github.com/OttoDIY/blockly/pull/52 in the master branch might create conflicts to the build in windows.

PS just forked your work and created linux_build branch and added few instructions to get you an idea of such details. It would be also good that you add GNU/Linux distribution and kernel as your work might be used/tested in other distributions of GNU/Linux and kernel versions.

gitaroktato commented 4 years ago

@agomezgar many thanks for all the help, basically everything I did was based on your work in masayloBlocklyLinux

I went ahead and added all the features to support Linux and Windows builds in the same repo. For this, I've separated the compilation folder's content in compilation/linux, compilation/win32 subfolders and added helper functions in the electronApp.js These helper functions change paths for HTML files and executables based on OS and development/production mode.

I've added separate build commands for Linux and Windows binaries in package.json

What should work by now: npm run debug and npm start runs the application in development mode, all without renaming paths manually. This should be both OK in Windows and Linux

npm run compiler-linux creates a Linux binary npm run compiler-win creates a Windows binary

Please check my changes and just let me know how I can help: Repo URL: https://github.com/gitaroktato/blockly/blob/linux_build Diff: https://github.com/OttoDIY/blockly/compare/master...gitaroktato:linux_build

agomezgar commented 4 years ago

It's what i'd planned to do in the next future... I'll check the code, @gitaroktato . Thanks a lot

mxochicale commented 4 years ago

Such a great job @agomezgar and @gitaroktato :)

In terms of workflow, perhaps you might like to mention that users have this branch https://github.com/OttoDIY/blockly/tree/versionlinux where other people can send PRs to contribute to the documentation and test in other GNU/Linux distributions.

cparrapa commented 4 years ago

awesome @agomezgar and @gitaroktato thanks a lot! @mxochicale mention where? so i think all the steps to install should be in the readme of this branch

mxochicale commented 4 years ago

Hi @cparrapa

Re:

@mxochicale mention where? so i think all the steps to install should be in the readme of this branch

You might like to add few lines in the README of the master branch to mention that the branch of versionlinux is ready for other people to test their robot using, at least, Ubuntu 18.04 or 20.04 : )

mxochicale commented 4 years ago

Hi @cparrapa @agomezgar and @gitaroktato

I have noticed that the version of OttoBlockly for versionlinux is v1.0.0. You might like to update it to its latest version 1.3.0. Perhaps, for future versions, such as 1.4.0, you might like to include in the changelog that OttoBlockly works for both windows and Ubuntu.

Thanks Miguel

cparrapa commented 4 years ago

Hi @mxochicale

I am really lost of how it work the linux version so not sure how to do a proper readme. Did it work for you what are the steps to install it?

No idea why is in a different version than Windows maybe is as @agomezgar established? or technically is the same 1.3.0. Blockly We are working in 1.4.0. but there is is a lot to handle how could we for examaple reflect the changes on the linux version?

Thanks!

mxochicale commented 3 years ago

Re: 1.3.0. Blockly mentioned above, I realised that your version 1.3.0 is showing 1.0.0: https://github.com/OttoDIY/blockly/blob/664059259fbbe96d3b1395f61394c1f1d08c83c0/package.json#L3

Perhaps, a minor changes has to be made to fix the appropriate version.

cparrapa commented 3 years ago

Hi @mxochicale

You are right so we make them match versions Thanks

mxochicale commented 3 years ago

Hi @cparrapa

It great to see the new version blockly with lots of nice new features https://github.com/OttoDIY/blockly/releases/tag/v1.4.0. Which makes me wonder: does blockly version 1.4.0 has been tested on its linuxversion counterpart?. If yes or not, I guess, you might like to close this issue and perhaps users can open new issues such as

Thanks Miguel

cparrapa commented 3 years ago

Hi @mxochicale

Glad you like them, unfortunately i do not have a computer with Linux to test it, i tried to install an ubuntu to an old laptop but it turn out to be even slower after flashing.

I was hoping you can test and somehow translate the changes to the Linux branch, it should be quite smooth.

Do you think is possible, I have some Raspberry PI also but no idea where to start?

I will close this issue then since it has been solved in this branch https://github.com/OttoDIY/blockly/tree/versionlinux

Thanks

mxochicale commented 3 years ago

Hi guys

just saw the amazing work of @agomezgar for the OttoBlockly Linux Version 1.4.2. (x64)

@agomezgar perhaps you would like to create a PR and update the current documentation of your work with the new version. It is always good to have a good documentation to allow the community to replicate your work. Happy to test your last version and review your PR if that is helpful.

Thanks Miguel