BallAerospace / COSMOS

Ball Aerospace COSMOS
https://ballaerospace.github.io/cosmos-website/
Other
360 stars 127 forks source link

Document Using COSMOS Bridges #1508

Open ghost opened 2 years ago

ghost commented 2 years ago

Primarily provide serial example, but maybe provide hints for FFI as well.

ghost commented 2 years ago
  1. Requires a host Ruby installation (Ruby 3)
  2. set host environment variable RUBYLIB=<Path to COSMOS/cosmos/lib folder>
  3. set host environment variable RUBYGEMS_URL=https://rubygems.org
  4. cd COSMOS/cosmos && bundle install && rake build && cd ../..
  5. ruby COSMOS/cosmos/bin/cosmos bridgesetup
  6. Edit the generated bridge configuration file (change serial port settings)
  7. ruby COSMOS/cosmos/bin cosmos bridge
  8. Change your plugin to connect to be a tcpip_client_interface instead of serial_interface and point host to host.docker.internal and appropriate port
  9. Install updated plugin to server
abdelrahman47 commented 2 years ago

when i try the third instruction (ruby COSMOS/cosmos/bin/cosmos bridgesetup) i get the following error <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:in require': cannot load such file -- cosmos/ext/platform (LoadError) from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:inrequire' from /home/lecogan/COSMOS-master/cosmos/lib/cosmos.rb:35:in <top (required)>' from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:inrequire' from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:in require' from cosmos/bin/cosmos:23:in

'

ghost commented 2 years ago

Ok. It is missing running "rake build" in the COSMOS/cosmos folder to build the C extensions. Do that, and then try ruby COSMOS\cosmos\bin\cosmos bridgesetup again

abdelrahman47 commented 2 years ago

okay when running "rake build" in COSMOS/cosmos folder. i get alos the same error

rake aborted! LoadError: cannot load such file -- yard <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:in require' <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:inrequire' /home/lecogan/COSMOS-master/cosmos/Rakefile:287:in <top (required)>' /usr/share/rubygems-integration/all/gems/rake-13.0.6/exe/rake:27:in<top (required)>' (See full trace by running task with --trace)

ghost commented 2 years ago

Now missing "bundle install", before "rake build".

abdelrahman47 commented 2 years ago

Now i get

There was an error parsing Gemfile: Unknown source ''. Bundler cannot continue. from /COSMOS/cosmos/Gemfile:3

source ENV['RUBYGEMS_URL']

ghost commented 2 years ago

Arg. Ok need to set RUBYGEMS_URL too.

abdelrahman47 commented 2 years ago

After setting RUBYGEMS_URL "source ENV['RUBYGEMS_URL']= 'https://www.rubygems.org'" and sucssesful exicuting "bundle install" and "rake build". Then tring ruby COSMOS\cosmos\bin\cosmos bridgesetup again the error didn't get fixed.

/var/lib/gems/3.0.0/gems/cosmos-0.0.6/lib/cosmos/service.rb:9: warning: already initialized constant Middleware::Runner::EMPTY_MIDDLEWARE /var/lib/gems/3.0.0/gems/middleware-0.1.0/lib/middleware/runner.rb:7: warning: previous definition of EMPTY_MIDDLEWARE was here <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:in require': cannot load such file -- cosmos/utilities/s3 (LoadError) from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:inrequire' from bin/cosmos:24:in `

'

ghost commented 2 years ago

Run: gem uninstall cosmos

I'm not sure how COSMOS 0.0.6 gets installed, but that breaks everything. COSMOS 5 is not (yet) installed as a gem. It gets added to the path through RUBYLIB variable in this example

abdelrahman47 commented 2 years ago

unfortunatlly even after running "gem uninstall cosmos" the error is still there. when trying to "run ruby COSMOS/cosmos/bin/cosmos bridgesetup"

<internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:in require': cannot load such file -- cosmos (LoadError) from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:inrequire' from COSMOS-master/cosmos/bin/cosmos:23:in `

'

ghost commented 2 years ago

Unless there is more to that message, it would indicate that RUBYLIB isn't set.
Do you have something like: export RUBYLIB=/home/USERNAME/COSMOS/cosmos/lib

If you do, you should be able to run 'irb' and then: require 'cosmos' and have it work

kmgraves commented 2 years ago

I am following this example on Windows with Ruby version 3.1.1

I get an error when running rake build

compiling crc.c
make: gcc: No such file or directory
make: *** [Makefile:246: crc.o] Error 127
rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - crc.so
C:/Users/{User}/COSMOS-temp/cosmos/Rakefile:155:in `block (2 levels) in <top (required)>'
C:/Users/{User}/COSMOS-temp/cosmos/Rakefile:147:in `each'
C:/Users/{User}/COSMOS-temp/cosmos/Rakefile:147:in `block in <top (required)>'

Here is output from running rake build --trace for more info

** Invoke build (first_time)
** Invoke devkit (first_time)
** Execute devkit
** Execute build
creating Makefile
generating crc-x64-mingw-ucrt.def
compiling crc.c
make: gcc: No such file or directory
make: *** [Makefile:246: crc.o] Error 127
rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - crc.so
C:/Ruby31-x64/lib/ruby/3.1.0/fileutils.rb:1394:in `initialize'
C:/Ruby31-x64/lib/ruby/3.1.0/fileutils.rb:1394:in `open'
C:/Ruby31-x64/lib/ruby/3.1.0/fileutils.rb:1394:in `copy_file'
C:/Ruby31-x64/lib/ruby/3.1.0/fileutils.rb:504:in `copy_file'
C:/Ruby31-x64/lib/ruby/3.1.0/fileutils.rb:423:in `block in cp'
C:/Ruby31-x64/lib/ruby/3.1.0/fileutils.rb:1577:in `block in fu_each_src_dest'
C:/Ruby31-x64/lib/ruby/3.1.0/fileutils.rb:1591:in `fu_each_src_dest0'
C:/Ruby31-x64/lib/ruby/3.1.0/fileutils.rb:1575:in `fu_each_src_dest'
C:/Ruby31-x64/lib/ruby/3.1.0/fileutils.rb:422:in `cp'
C:/Users/{User}/COSMOS-temp/cosmos/Rakefile:155:in `block (2 levels) in <top (required)>'
C:/Users/{User}/COSMOS-temp/cosmos/Rakefile:147:in `each'
C:/Users/{User}/COSMOS-temp/cosmos/Rakefile:147:in `block in <top (required)>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
C:/Ruby31-x64/bin/rake:33:in `load'
C:/Ruby31-x64/bin/rake:33:in `<main>'
Tasks: TOP => build
ghost commented 2 years ago

You'll need to have the Ruby Installer + Devkit from rubyinstaller.org to compile the C extensions. Did you install the Devkit version?

kmgraves commented 2 years ago

I had the Devkit installed, but I missed a step in setting it up. I needed to do ridk enable in my cmd. After that it ran with no issues. Thank you!

DavidWathen commented 2 years ago

Running on Ubuntu 18.04

I'm trying to follow the steps to setup cosmos bridges but I'm having a problem.

I have done the following:

I then get the following error:

<internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in require': cannot load such file -- zlib (LoadError) from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:inrequire' from /usr/local/lib/ruby/3.1.0/bundler/fetcher.rb:6:in `<top (required)>'

Can someone please help me resolve this.

ghost commented 2 years ago

You were probably missing the zlib-devel package when you built ruby. (maybe zlib1g-dev on Ubuntu). Probably need to apt install that and rebuild ruby.

DavidWathen commented 2 years ago

I ran:

When I rebuild ruby I noticed the following:

Following extensions are not compiled: zlib: Could not be configured. It will not be installed. Check ext/zlib/mkmf.log for more details. Fix the problems, then remove these directories and try again if you want.

When I look at mkmf.log for zlib I find various undeclared errors for deflateReset

error: ‘deflateReset’ undeclared (first use in this function)

Any ideas?

ghost commented 2 years ago

This has the recommended apt installs for building ruby:

https://github.com/docker-library/buildpack-deps/blob/65d69325ad741cea6dee20781c1faaab2e003d87/debian/buster/Dockerfile

and then this:

https://github.com/docker-library/ruby/blob/6a100006eeb52ec06bfe3f318b401cdf5a52dd6b/3.1/buster/Dockerfile

These are against Debian buster (Ubuntu 20.04 equiv), but should be similar

DavidWathen commented 2 years ago

Thanks so much for your help Ryan!

I was able to successfully build ruby, run bundle install and rake build.

I then generated my bridge.txt file, modified it and ran "ruby COSMOS/cosmos/bin cosmos bridge"

{"time":1650326922815774501,"@timestamp":"2022-04-18T18:08:42.815-06:00","severity":"INFO","container_name":"precision-vm","log":"Processing Bridge configuration in file: /home/precision/bridge.txt"} {"time":1650326922831452668,"@timestamp":"2022-04-18T18:08:42.831-06:00","severity":"INFO","container_name":"precision-vm","log":"Starting packet reading for DRACO_INT"} {"time":1650326922831679724,"@timestamp":"2022-04-18T18:08:42.831-06:00","severity":"INFO","container_name":"precision-vm","log":"Connecting to DRACO_INT..."} {"time":1650326922831989559,"@timestamp":"2022-04-18T18:08:42.831-06:00","severity":"INFO","container_name":"precision-vm","log":"Starting packet reading for SERIAL_ROUTER"} {"time":1650326922832073922,"@timestamp":"2022-04-18T18:08:42.832-06:00","severity":"INFO","container_name":"precision-vm","log":"Connecting to SERIAL_ROUTER..."} {"time":1650326922832227660,"@timestamp":"2022-04-18T18:08:42.832-06:00","severity":"INFO","container_name":"precision-vm","log":"DRACO_INT Connection Success"} {"time":1650326922832693140,"@timestamp":"2022-04-18T18:08:42.832-06:00","severity":"INFO","container_name":"precision-vm","log":"SERIAL_ROUTER Connection Success"}

I updated my plugin.txt file to use a tcp-ip interface.

INTERFACE <%= draco_target_name %>_INT tcpip_client_interface.rb host.docker.internal 8080 8081 10.0 nil BURST MAP_TARGET <%= draco_target_name %>

I'm getting the following error when Cosmos tries to connect to my interface.

DRACO_INT: RuntimeError : Invalid hostname: host.docker.internal

I'm so close and excited!

Can you help me in how I need to properly configure the tcp ip client interface for the bridge?

David

ghost commented 2 years ago

Try: 172.17.0.1 instead of host.docker.internal

https://stackoverflow.com/questions/48546124/what-is-linux-equivalent-of-host-docker-internal

If that doesn't work then we'll need to dig into your docker install a bit more

DavidWathen commented 2 years ago

I'm now getting

DRACO_INT: Connection Failed: ECONNREFUSED : Connection refused - connect(2) for 172.17.0.1:8080

On the console that the I'm running "ruby COSMOS/cosmos/bin cosmos bridge" I noticed the following:

{"time":1650329273466803495,"@timestamp":"2022-04-18T18:47:53.466-06:00","severity":"INFO","container_name":"precision-vm","log":"SERIAL_ROUTER: Tcpip server accepted connection from UNKNOWN(172.29.0.6):49656"} {"time":1650329277815833528,"@timestamp":"2022-04-18T18:47:57.815-06:00","severity":"INFO","container_name":"precision-vm","log":"SERIAL_ROUTER: Tcpip server lost read connection to UNKNOWN(172.29.0.6):49656"} ... ... {"time":1650329277873404330,"@timestamp":"2022-04-18T18:47:57.873-06:00","severity":"INFO","container_name":"precision-vm","log":"SERIAL_ROUTER: Tcpip server lost write connection to UNKNOWN(172.29.0.6):49250"}

... ...

ghost commented 2 years ago

Can you share your bridge config file, and plugin INTERFACE lines? I think the default bridge config uses port 2950 instead of 8080, but it seems close to connecting so that's probably not the issue. It feels like the connection is working in one direction, so maybe some kind of firewall issue

ghost commented 2 years ago

Also are you trying this with rootless docker?

DavidWathen commented 2 years ago

I don't think I'm using rootless docker. I admit I wasn't even sure what it was so I googled. I did not taken any steps to configure it. Is there a way I would know for sure?

DavidWathen commented 2 years ago

Bridge.txt:

    INTERFACE SERIAL_INT serial_interface.rb /dev/pts/6 /dev/pts/6 9600 NONE 1 10.0 nil BURST

    ROUTER SERIAL_ROUTER tcpip_server_interface.rb 2950 2950 10.0 nil BURST
      # ROUTE <Interface Name>
      ROUTE SERIAL_INT

plugin.txt VARIABLE draco_target_name DRACO

TARGET DRACO <%= draco_target_name %>
 INTERFACE <%= draco_target_name %>_INT tcpip_client_interface.rb 172.17.0.1 8080 8081 10.0 nil BURST
  MAP_TARGET <%= draco_target_name %>
ghost commented 2 years ago

Replace 8080 8081 in plugin.txt with 2950 2950

DavidWathen commented 2 years ago

Wahoo!!!!

It's up and running now.

Thank you sooooooo much!!!

DavidWathen commented 2 years ago

Hi Ryan,

Thanks again for all your help getting my bridge going!

I was wondering if you could point me in the right direction and offer some hints on debugging the bridge code. I have a defined 6 simple cmds and can receive all of them successfully except for one. For some reason if the id, used for PKTID, is set to 3 then I will not receive the last byte of the packet which is this ID. If I just change this to another value, i.e. 7, then I receive it no problem.

I appreciate any hints you have.

Thanks,

David

--------------------------------_ccsds_cmd.txt------------------------------------------------

PARAMETER CCSDSVER 0 3 UINT 0 0 0 "CCSDS primary header version number" PARAMETER CCSDSTYPE 3 1 UINT 1 1 1 "CCSDS primary header packet type" PARAMETER CCSDSSHF 4 1 UINT 0 0 0 "CCSDS primary header secondary header flag" ID_PARAMETER CCSDSAPID 5 11 UINT 0 2047 999 "CCSDS primary header application id" PARAMETER CCSDSSEQFLAGS 16 2 UINT 3 3 3 "CCSDS primary header sequence flags" PARAMETER CCSDSSEQCNT 18 14 UINT 0 16383 0 "CCSDS primary header sequence count" OVERFLOW TRUNCATE PARAMETER CCSDSLENGTH 32 16 UINT MIN MAX 2 "CCSDS primary header packet length" ID_PARAMETER PKTID 48 16 UINT MIN MAX <%= id %> "Packet id"


--------------------------------cmds.txt------------------------------------------------------- COMMAND TEST TRANSFER_EVENT_SUMMARY BIG_ENDIAN "Send event summary" <%= render "_ccsds_cmd.txt", locals: {id: 1} %>

COMMAND TEST TRANSFER_EVENT_DATA BIG_ENDIAN "Send event data" <%= render "_ccsds_cmd.txt", locals: {id: 2} %>

COMMAND TEST TRANSFER_HS_DATA_BUF BIG_ENDIAN "Send high speed data buffer" <%= render "_ccsds_cmd.txt", locals: {id: 3} %>

COMMAND TEST SUCCESSFUL_DOWNLINK BIG_ENDIAN "Indication that a successful downlink occurred. Trigger delete of event record" <%= render "_ccsds_cmd.txt", locals: {id: 4} %>

COMMAND TEST CHANGE_PARAMENTER BIG_ENDIAN "Change parameter" <%= render "_ccsds_cmd.txt", locals: {id: 5} %>

COMMAND TEST NOOP BIG_ENDIAN "No-op command" <%= render "_ccsds_cmd.txt", locals: {id: 6} %>


This will work if I just change 3 to 7.

COMMAND TEST TRANSFER_HS_DATA_BUF BIG_ENDIAN "Send high speed data buffer" <%= render "_ccsds_cmd.txt", locals: {id: 7} %>

ghost commented 2 years ago

I don't have a specific reason for the 3 versus 7 thing, but my guess is it is because you are putting the wrong value into the CCSDS_LENGTH field. For CCSDS source packets, a length of 0 = 1 byte of data. So for your packets with 2 bytes of data, the CCSDS_LENGTH field should be set to 1 (not 2).

bradley-harden-apl commented 2 years ago

@ryanatball, we were able to get the ethernet bridge working on Windows. However, I'm trying to get it working with podman on an Ubuntu 20.04 machine. I've run into an issue, and I'm not sure if/what the solution might be.

It looks like host.docker.internal is supported with podman, but I found the following comment in that thread:

This sounds expected, then, given the limitations of the rootless network stack. The "host" in the rootless sense is not a pointer to an IP on the host, but to the internal slirp4netns IP where traffic from the host originates. Rootless does not have the privileges required to configure proper network bridges, so instead traffic is tunneled from the host into the container; a side effect of this is that communication from host to container is limited to only forwarded ports. There is an option to expose the host's localhost into the container, albeit there are security implications to doing so (applications binding to localhost on the assumption that it is not shared)

Does that imply it would not be possible to use the bridge in its current form? I tried adding networking_mode: "host" to the compose.yaml file, but that seemed to mess things up.

Do you have any ideas on a possible solution?

Edit: Maybe a solution is to manually forward port 2950?

Update: I tried to get this working with some combination of port forwarding, socat and iptables, but I've pretty much hit the limits of my knowledge of Linux networking.

ghost commented 2 years ago

I haven't tried getting to the host from podman yet, so I can't answer if that works or not.

A good solution would probably be to swap the client/server design. Make the bridge be a tcpip_client_interface that connects to COSMOS, and have the COSMOS Interface be a tcpip_server_interface. You'll need to open up whatever port you use in compose.yaml for the cosmos-operator process as well.

bradley-harden-apl commented 2 years ago

@ryanatball, is it as simple as changing the interface type in the bridge and plugin files?

ghost commented 2 years ago

@bradley-harden-apl It should be mostly swapping the bridge ROUTER line parameters and the plugin INTERFACE line parameters, and then opening the port in compose.yaml to the cosmos-operator container.

ghost commented 2 years ago

The BRIDGE router would then connect to "localhost"

ghost commented 2 years ago

Note, it is still a ROUTER in the bridge, and an INTERFACE in the plugin.

bradley-harden-apl commented 2 years ago

I was just about to ask that

bradley-harden-apl commented 2 years ago

@ryanatball, it looks like that doesn't work. Or maybe I did something wrong.

Like you said, I brought down COSMOS, added

ports:
  - "2950:2950"

to the cosmos-operator service, and brought it back up with cosmos-control.sh run.

Then I swapped the client and server interfaces, and made the client point to localhost. The plugin seems to load correctly and gives no errors. However, the bridge fails to connect, giving a connection refused - connect(2) for 127.0.0.1:2950.

Any ideas?

ghost commented 2 years ago

That should work. Can you share your exact config lines?

bradley-harden-apl commented 2 years ago

bridge.txt:

# Example Host Bridge Configuration for a Serial Port
#
# Run in COSMOS/ directory: $ cosmos bridge bridge.txt
#
# INTERFACE <Interface Name> <Interface File> <Interface Params...>
INTERFACE OPAL_KELLY_INT serial_interface.rb /dev/ttyUSB0 /dev/ttyUSB0 115200 ODD 1 10.0 nil BURST

# ROUTER <Router Name> <Interface File> <Interface Params...>
ROUTER SERIAL_ROUTER tcpip_client_interface.rb localhost 2950 2950 10.0 nil BURST
  # ROUTE <Interface Name>
  ROUTE OPAL_KELLY_INT

plugin.txt:

# Set VARIABLEs here to allow variation in your plugin
# See https://cosmosc2.com/docs/v5/plugins for more information
VARIABLE opal_kelly_target_name OPAL_KELLY

# Modify this according to your actual target connection
# See https://cosmosc2.com/docs/v5/interfaces for more information
TARGET OPAL_KELLY <%= opal_kelly_target_name %>
INTERFACE <%= opal_kelly_target_name %>_INT tcpip_server_interface.rb 2950 2950 10.0 nil BURST
  MAP_TARGET <%= opal_kelly_target_name %>
bradley-harden-apl commented 2 years ago

Alternatively, maybe it would be easier to just expose /dev/ttyUSB0 to the right container and get rid of the bridge altogether? What would that look like? Just a device section added to compose.yaml? I think you said it would need to be run in --privileged mode, but is that the case for podman as well? I think you can access devices in rootless containers if you place yourself in the dialout group and forward your groups into the container. I've never done it myself, but I've seen it mentioned before.

ghost commented 2 years ago

Still don't see anything wrong with your config. Check the CmdTlmServer log messages and interfaces tab and make sure the INTERFACE is happy and running.

Then maybe do a netstat or something to see if the port is open and listening on localhost (should be if the compose line worked).

I think getting devices into rootless Podman is probably not going to work... Should be possible with normal Docker

bradley-harden-apl commented 2 years ago

The plugin looks happy. I only see "Connection requested", "Connecting ..." and "Connection Success".

Maybe adding devices and group_add to compose.yaml would work. I think that addresses the two issues. I'll give that a try and report back.

bradley-harden-apl commented 2 years ago

Ah, no, that won't work. group_add adds you to the group within the container, but that's a different group than the host group. podman has the option --group-add keep-groups, and it is only able to keep the user's groups with a special ability of crun. Since runc does not support this, and probably never will, I think I can safely assume that docker-compose will never expose an option to include the --group-add keep-groups option.

Edit with link for posterity

bradley-harden-apl commented 2 years ago

OH! Duh....

sudo chmod 666 /dev/ttyUSB0

That's way simpler than an ethernet bridge or trying to get groups forwarded into the container. And even though I don't really care about security, it wouldn't even be a security risk if I did, because it's just a serial port.

It looks like that works, so I think it will be my path forward.

bradley-harden-apl commented 2 years ago

@ryanatball, I was able to fix the inverted ethernet bridge. I had forgotten that I modified my iptables, which was disrupting the connection. Once I removed those entries, the client bridge and server plugin approach works with the port forwarded to the container.

ghost commented 2 years ago

@bradley-harden-apl I'm glad you got this working. Could you please post your final solution of plugin.txt, bridge.txt and whatever changes you needed to make to the compose.yaml? I'm sure this will help others with the same issue.

bradley-harden-apl commented 2 years ago

plugin.txt:

TARGET OPAL_KELLY OPAL_KELLY

INTERFACE OPAL_KELLY_INT tcpip_server_interface.rb 2950 2950 10.0 nil BURST

MAP_TARGET OPAL_KELLY

bridge.txt:

INTERFACE OPAL_KELLY_INT serial_interface.rb /dev/ttyUSB0 /dev/ttyUSB0 115200 ODD 1 10.0 nil BURST

ROUTER SERIAL_ROUTER tcpip_client_interface.rb localhost 2950 2950 10.0 nil BURST
ROUTE OPAL_KELLY_INT

compose.yaml:

diff --git a/compose.yaml b/compose.yaml
index 3133b162..616c5391 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -86,6 +86,8 @@ services:
       - ".env"
     extra_hosts:
       - host.docker.internal:host-gateway
+    ports:
+      - "2950:2950"
bradley-harden-apl commented 2 years ago

Here is my other solution, where the device is mounted into the container:

plugin.txt:

TARGET OPAL_KELLY OPAL_KELLY

INTERFACE OPAL_KELLY_INT serial_interface.rb /dev/ttyUSB0 /dev/ttyUSB0 115200 ODD 1 10.0 nil BURST

MAP_TARGET OPAL_KELLY

No bridge

compose.yaml:

diff --git a/compose.yaml b/compose.yaml
index 3133b162..4db43d7b 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -86,6 +86,8 @@ services:
       - ".env"
     extra_hosts:
       - host.docker.internal:host-gateway
+    devices:
+      - "/dev/ttyUSB0:/dev/ttyUSB0"

In a shell:

sudo chmod 666 /dev/ttyUSB0
ryanmelt commented 1 year ago

Documented here: https://openc3.com/docs/v5/bridges