Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible port to linux? #5

Closed
cprpolo opened this issue Mar 10, 2018 · 35 comments
Closed

Possible port to linux? #5

cprpolo opened this issue Mar 10, 2018 · 35 comments

Comments

@cprpolo
Copy link

cprpolo commented Mar 10, 2018

Hi, is there any chance of an executable for linux (rpm or deb)? mainly interested in the multiwii part where you use the Flight controller connected to the PC.
or any advice for compilation if it would be doable with the same code?

Thank you for this work :)

@Cleric-K
Copy link
Owner

Hi,
the c# code compiles as a .NET executable so in theory it should run on any platform with Mono for example. But the problem is that vJoy is a Windows driver - does not work on anything else.
If something analogous to vJoy is found for linux it could be possible I guess.

The problem is similar with MacOS.

I'll have to take a look.
Hi,
the c# code compiles as a .NET executable so in theory it should run on any platform with Mono for example. But the problem is that vJoy is a Windows driver - does not work on anything else.
If something analogous to vJoy is found for linux it could be possible I guess.

The problem is similar with MacOS.

I'll have to take a look.

@cprpolo
Copy link
Author

cprpolo commented Mar 10, 2018

I guessed that. I found this : https://github.com/izissise/Linux-Virtual-Joystick-cpp
Pretty old but may be helpful. Thank you for taking a look ;)

1 similar comment
@cprpolo
Copy link
Author

cprpolo commented Mar 10, 2018

I guessed that. I found this : https://github.com/izissise/Linux-Virtual-Joystick-cpp
Pretty old but may be helpful. Thank you for taking a look ;)

@Cleric-K
Copy link
Owner

Hi, I don't know when or if I'll be able to port the actual vJoySerialFeeder to Linux, but I've created a simple script that might help you. I hope you find your way in Linux because there are some steps:

  1. Create a directory and create in it a mwjoy.py file with this contents.
  2. Create another file in the same directory called msp.py with this contents.
  3. Install pip if not present. sudo apt-get install python-pip if you are on a debian based distro.
  4. Execute pip install python-uinput
  5. Go to the directory you created and execute sudo python mwjoy.py SERIAL_DEV where you replace SERIAL_DEV with the serial device (/dev/ttyUSB0, /dev/ttyACM0 or something like that).
  6. While the script is running you should have a virtual joystick.

Let me know if that works.

@Cleric-K
Copy link
Owner

Oh, I forgot: you also need pip install pyserial

@cprpolo
Copy link
Author

cprpolo commented Mar 11, 2018

hi, thanks very much for looking into this.

Here is what i got:
~/Documents/vjoy$ sudo python mwjoy.py /dev/ttyACM0
Waking up board on /dev/ttyACM0...
1
Traceback (most recent call last):
File "mwjoy.py", line 18, in
with uinput.Device(events) as device:
File "/usr/local/lib/python2.7/dist-packages/uinput/init.py", line 178, in init
self.__uinput_fd = fd or fdopen()
File "/usr/local/lib/python2.7/dist-packages/uinput/init.py", line 84, in fdopen
return _libsuinput.suinput_open()
File "/usr/local/lib/python2.7/dist-packages/uinput/init.py", line 68, in _open_error_handler
raise OSError(code, "%s. Perhaps load the uinput kernel module first?" % msg)
OSError: [Errno 2] Failed to open the uinput device: No such file or directory. Perhaps load the uinput kernel module first?

I am having issues connecting the board to betaflight also...so may be that the reason
hope I did all good and this helps

@cprpolo
Copy link
Author

cprpolo commented Mar 11, 2018

Okay, after another board's tests seems that when i plugged the board i can connect to betaflight no issues.
When i run the script, i get the error above and after that the connection to betaflight is intermittent (not always connects)
if I unplug the usb and plug it again, i may get a different ttyUSBx or ttyACMx, but same behavior

I'll test more if i can
thanks

@cprpolo
Copy link
Author

cprpolo commented Mar 11, 2018

Also a msp.pyc was created in the directory, binary values.

@Cleric-K
Copy link
Owner

The error is because the uinput device does not exists. What linux distro are you using?
Try sudo modprobe uinput

@cprpolo
Copy link
Author

cprpolo commented Mar 12, 2018

okay, after doing sudo modprobe uinput worked
~/Documents/vjoy$ sudo python mwjoy.py /dev/ttyUSB0
Waking up board on /dev/ttyUSB0...
1
working ...
That's great :)
what else should i try? :)

@Cleric-K
Copy link
Owner

Does it work in your sim now? (while the script is running of course)

@cprpolo
Copy link
Author

cprpolo commented Mar 12, 2018

no, it is not detected in velocidrone

@Cleric-K
Copy link
Owner

Hmm.. I have tested with jstest-gtk and it finds it.
Can you install it and give it a try?
Also, while you are running you should see in /dev/input/
something like js0.

@cprpolo
Copy link
Author

cprpolo commented Mar 12, 2018

just tested it, it appears as js1, but it is not detected.
i am using debian btw, any possible permissions issue? jstest-gtk with sudo does not make any difference

@Cleric-K
Copy link
Owner

Cleric-K commented Mar 12, 2018

I don't really know. I'm testing with Ubuntu 16.04 here.
What about: jstest /dev/input/js1 with or without sudo (it's in the joystick package, if you don't have it installed).

Another test is hd /dev/input/js1 this should dump hex values of the raw joystick events. They should be running all the time. Stop with Ctrl-C.

What Deb release/kernel version?

@cprpolo
Copy link
Author

cprpolo commented Mar 12, 2018

jstest-gtk /dev/input/js1
Gtk-Message: Failed to load module "canberra-gtk-module"

(jstest-gtk:3786): GLib-GObject-WARNING **: value "0" of type 'guint' is invalid or out of range for property 'n-columns' of type 'guint'
Warning: unknown joystick, not displaying graphical representation

that's what i get in the terminal, but in the gui no movement
Debian 8
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u5 (2017-09-19) x86_64 GNU/Linux

@Cleric-K
Copy link
Owner

No, not jstest-gtk, just jstest - that's cli program.

Try also to replace mw.py with this version. It adds on line 22 a print. It should dump the multiwii packets as they are read from the fc.

@cprpolo
Copy link
Author

cprpolo commented Mar 12, 2018

i think is working without the new version that you just posted. But can't get it in velocidrone and the yaw is not working
At this point i think it is something in my pc, i need more time to check it, is it working for you? my pc keeps changing the uarts for some reason, i think that's the issue...did you test velocidrone?
maybe someone else can test on linux?

@Cleric-K
Copy link
Owner

Check this again. I changed the axes. Also put a button just in case (although it is not used).

When you run the debug version do you see stuff like:

{'throttle': 1504, 'timestamp': '1520885596.43', 'yaw': 1504, 'elapsed': 0.01, 'pitch': 1504, 'roll': 1504}
{'throttle': 1504, 'timestamp': '1520885596.44', 'yaw': 1504, 'elapsed': 0.01, 'pitch': 1504, 'roll': 1504}
{'throttle': 1504, 'timestamp': '1520885596.45', 'yaw': 1504, 'elapsed': 0.01, 'pitch': 1504, 'roll': 1504}
{'throttle': 1504, 'timestamp': '1520885596.46', 'yaw': 1504, 'elapsed': 0.01, 'pitch': 1504, 'roll': 1504}
{'throttle': 1504, 'timestamp': '1520885596.47', 'yaw': 1504, 'elapsed': 0.01, 'pitch': 1504, 'roll': 1504}

Where do you see the yaw not working? I the debug output or in the jtest output?

I don't have any games on this linux so I can't test. I'll download fpvfreerider linux demo now and see.

@Cleric-K
Copy link
Owner

Works fine in freerider.

cleric@ubuntu:~/games/FpvFreerider$ ./FPVFreerider_demo.x86_64
Set current directory to /home/cleric/games/FpvFreerider
Found path: /home/cleric/games/FpvFreerider/FPVFreerider_demo.x86_64
Mono path[0] = '/home/cleric/games/FpvFreerider/FPVFreerider_demo_Data/Managed'
Mono path[1] = '/home/cleric/games/FpvFreerider/FPVFreerider_demo_Data/Mono'
Mono config path = '/home/cleric/games/FpvFreerider/FPVFreerider_demo_Data/Mono/etc'
displaymanager : xrandr version warning. 1.5
client has 1 screens
displaymanager screen (0)(default): 1280 x 1024
Using libudev for joystick management


Importing game controller configs
/dev/input/js0: driver version: 2.1.0 (20100)
/dev/input/js0: fd 4, buttons 0, axes 4, name python-uinput
/dev/input/js0: axis  0: raw     65, mapped 0.000000
/dev/input/js0: axis  1: raw      0, mapped 0.000000
/dev/input/js0: axis  2: raw -32767, mapped 0.000000
/dev/input/js0: axis  3: raw    131, mapped 0.000000
Assigning joystick 1

@cprpolo
Copy link
Author

cprpolo commented Mar 12, 2018

hi, I can see it in velocidrone, i updated the debian and rebooted.
The yaw is not working though, either in jtest or the velocidrone, however in the debug i can see it changing
I'll try fpv Freerider also
thank you for your work

@Cleric-K
Copy link
Owner

That's strange. Here's something to try:
at the lines:

device.emit(uinput.ABS_X, (state['roll']-1500)*32767/500, syn=False)
device.emit(uinput.ABS_Y, (state['pitch']-1500)*32767/500, syn=False)
device.emit(uinput.ABS_Z, (state['throttle']-1500)*32767/500, syn=False)
device.emit(uinput.ABS_RX , (state['yaw']-1500)*32767/500)

Exchange for example ABS_X with ABS_RX. If the problem is in the RX axis, then it should stop working for roll and start working for yaw. I yaw does not work again, then maybe the problem will be in the emit itself, which will be odd.

@cprpolo
Copy link
Author

cprpolo commented Mar 12, 2018

okay... got it... the indentation on the last line (yaw one) was bad and the if was not taking it... moved it and it is working now! :)
thank you very much!!!
works great in velocidrone! thank you

@Cleric-K
Copy link
Owner

Well, that's great news!
I'm glad it worked out. Now that we know that the uinput device can do the job, I'll see if I can implement it in vjoyserialfeeder.
People are also interested in MacOS, but this is even more distant goal - since I've never even used a Mac :) let alone programmed for it.

One last thing: If you haven't done so, you can comment (#) or remove the print(state) line. It will save you a few CPU cycles.

Happy flying! :)

@cprpolo
Copy link
Author

cprpolo commented Mar 13, 2018 via email

@Cleric-K
Copy link
Owner

Hi @cprpolo ,
Are you interested in trying out a linux port of vJSF?

@cprpolo
Copy link
Author

cprpolo commented Mar 23, 2018 via email

@Cleric-K
Copy link
Owner

Ok, don't worry, anytime you can.
I'll try to prepare a build today.

@cprpolo
Copy link
Author

cprpolo commented Mar 23, 2018 via email

@Cleric-K
Copy link
Owner

Alright, here are some binaries:
https://www.dropbox.com/sh/0jhgb2tmyzd6ffh/AADFS1xkD0YWIc3C_gwl1ABqa?dl=0

Since vjsf is written in C# in needs .NET Runtime - for linux that is Mono.

The two files vJoySerialFeeder_32 and .._64 are bundles which are native ELF executables and they should contain all the necessary runtime stuff inside (that's why they are so big). You'll have to do chmod +x ...

If you have mono installed you can simply: mono vJoySerialFeeder.exe

If you want to run as non-root, you'll have to do something like sudo chmod a+wr /dev/uinput (this will be reset to the default on reboot). There is a more elegant way ( https://tkcheng.wordpress.com/2013/11/11/changing-uinput-device-permission/ ) but chmod is faster if you just want to make the test.
You also have to make sure your user is part of the dialout group if you want to be able to access serial ports as non-root.

Cleric-K added a commit that referenced this issue Apr 13, 2018
New features compared to v1.2:
* Process Interaction (COM and WebSocket)
* Lua Scripting
* Failsafe #4
* Linux support #5
* vXbox support #8
* Import/Export configuration #10
* Trigger buttons
* KISS protocol support
@Cleric-K
Copy link
Owner

Hi,

I've uploaded a new release. It should support Linux. You can check it out.

@cprpolo
Copy link
Author

cprpolo commented Apr 16, 2018 via email

@Cleric-K
Copy link
Owner

Hi, here's a 7z file https://www.dropbox.com/s/qr6vc5osjah0q5i/vjsf_linux.7z?dl=0
I used tar because it preserves file attributes. Now you'll have to manually set the standalone files to executable after extract.

@cprpolo
Copy link
Author

cprpolo commented Apr 17, 2018 via email

@Cleric-K
Copy link
Owner

Hi,
I did some tests and it turns out that these standalone versions are not going to work. Seems that the native libraries are still needed to be installed locally. For example, in your case libgdiplus.so is needed. I tried to include that into the standalone bundle but then libgdiplus.so itself has still other dependencies and so on.

So I guess I'll remove the standalone versions from the releases.

In that case the only solution left is to install Mono.

If you are interested you'll have to follow the instructions at https://www.mono-project.com/download/stable/#download-lin-debian for your platform, then download the mono release of vjsf and start from console with mono vJoySerialFeeder.exe.

But if you don't want to go through all this - it is fine, don't waste your time.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants