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

Serial interface #INTERFACE_NAME: Connection Failed: ENOENT : No such file or directory @ rb_sysopen - /dev/ttyACM0 #1498

Closed
abdelrahman47 opened this issue Mar 29, 2022 · 10 comments

Comments

@abdelrahman47
Copy link

I am tring to connect serial interface on linux based machine I get those errors:

Plugin Interface:
INTERFACE INTERFACE_NAME serial_interface.rb /dev/ttyACM0 /dev/ttyACM0 115200 NONE 1 10.0 10.0 # no built-in protocol

INTERFACE_NAME: ENOENT : No such file or directory @ rb_sysopen - /dev/ttyACM0 /cosmos/lib/cosmos/io/posix_serial_driver.rb:55:in initialize' /cosmos/lib/cosmos/io/posix_serial_driver.rb:55:in open' /cosmos/lib/cosmos/io/posix_serial_driver.rb:55:in initialize' /cosmos/lib/cosmos/io/serial_driver.rb:67:in new' /cosmos/lib/cosmos/io/serial_driver.rb:67:in initialize' /cosmos/lib/cosmos/streams/serial_stream.rb:74:in new' /cosmos/lib/cosmos/streams/serial_stream.rb:74:in initialize' /cosmos/lib/cosmos/interfaces/serial_interface.rb:68:in new' /cosmos/lib/cosmos/interfaces/serial_interface.rb:68:in connect' interface_microservice.rb:477:in connect' interface_microservice.rb:319:in block in run' interface_microservice.rb:317:in synchronize' interface_microservice.rb:317:in run' /cosmos/lib/cosmos/microservices/microservice.rb:47:in run' interface_microservice.rb:549:in `

'

Also tried to follow up with this solution but problem didn't fixed.

@ghost ghost added this to the questions milestone Mar 29, 2022
@ghost
Copy link

ghost commented Mar 29, 2022

The host serial interfaces are not available to containers (generally). If you are on a linux host, it is possible to make them available, but you still will probably run into permissions issues to work through.

The bridge solution that you referenced was created to solve this (connecting to the serial port directly on the host and then serving the data to COSMOS through a TCP connection).

Just connecting to the serial port you are referencing on the host is the first debugging step. Can you access /dev/ttyACM0 from any application?

@abdelrahman47
Copy link
Author

Thanks for the quick reply,
yes i can access /dev/ttyACM0 from different applications.
i see that the bridge solution will fix the problem. but is there a documentation for it cuz I am new to cosmos.

how it works? how to connect? how to make sure that it works?

@ghost
Copy link

ghost commented Mar 30, 2022

Unfortunately we don't have great documentation for this yet. If you run:

cosmos-control.bat cosmos bridgesetup ACM0_bridge.txt

That should setup the bridge for you. Edit the values in that file to match your local settings. Then run

cosmos-control.bat cosmos bridge ACM0_bridge.txt

To run the bridge. Note this will just sit there running. You'll want to setup your local plugin (see https://cosmosc2.com/docs/v5/gettingstarted for more info) to connect to the local machine on port 2950 (by default) and you can start COSMOS with:

cosmos-control.bat start

To connect to it.

@abdelrahman47
Copy link
Author

After following the steps i get error: Connection Failed: ECONNREFUSED : Connection refused - connect(2) for 127.0.0.1:2950.
the interface cant connect to router also tried from windows host and got the same error.
on windows tried to turn off the firewall and still no connection.

INTERFACE INTERFACE_NAME tcpip_client_interface.rb localhost 2950 2950 10.0 nil BURST
ROUTER SERIAL_ROUTER tcpip_server_interface.rb 2950 2950 10.0 nil BURST

@ghost
Copy link

ghost commented Apr 4, 2022

Is that the configuration inside your plugin.txt file?
If so, you should not connect to localhost (localhost in containers is not the same as the host localhost).

Change localhost to host.docker.internal

Also, the bridge will need to be running before doing this or it also won't be able to connect.

@abdelrahman47
Copy link
Author

also when i changed to host.docker.internal i got the same error but different IP address: connection Failed: ECONNREFUSED : Connection refused - connect(2) for 172.17.0.1:2950

plugin.txt: INTERFACE INTERFACE_NAME tcpip_client_interface.rb host.docker.internal 2950 2950 10.0 nil BURST

name_bridge.txt: ROUTER SERIAL_ROUTER tcpip_server_interface.rb 2950 2950 10.0 nil BURST

The router is connected.
Screenshot from 2022-04-05 01-00-14

@ghost
Copy link

ghost commented Apr 4, 2022

INST_ROUTER is not the same as SERIAL_ROUTER. SERIAL_ROUTER is in the bridge. Is the bridge code running and connected to the serial port?

@abdelrahman47
Copy link
Author

The SERIAL_ROUTER is not running. and when I run the command (cosmos-control.sh cosmos bridge ACM0_bridge.txt
) I get this error.
i see it is still looking for /dev/ttyACM0 at (No such file or directory @ rb_sysopen - /dev/ttyACM0)

{"time":1649267727456170894,"@timestamp":"2022-04-06T17:55:27.456+00:00","severity":"INFO","container_name":"eabe8281b9a3","log":"Processing Bridge configuration in file: /cosmos/local/ACM0_bridge.txt"}
{"time":1649267727483534609,"@timestamp":"2022-04-06T17:55:27.483+00:00","severity":"INFO","container_name":"eabe8281b9a3","log":"Starting packet reading for SERIAL_INT"}
{"time":1649267727483598053,"@timestamp":"2022-04-06T17:55:27.483+00:00","severity":"INFO","container_name":"eabe8281b9a3","log":"Connecting to SERIAL_INT..."}
{"time":1649267727483734944,"@timestamp":"2022-04-06T17:55:27.483+00:00","severity":"INFO","container_name":"eabe8281b9a3","log":"Starting packet reading for SERIAL_ROUTER"}
{"time":1649267727483774521,"@timestamp":"2022-04-06T17:55:27.483+00:00","severity":"INFO","container_name":"eabe8281b9a3","log":"Connecting to SERIAL_ROUTER..."}
{"time":1649267727484026021,"@timestamp":"2022-04-06T17:55:27.484+00:00","severity":"INFO","container_name":"eabe8281b9a3","log":"SERIAL_ROUTER Connection Success"}
{"time":1649267727484175952,"@timestamp":"2022-04-06T17:55:27.484+00:00","severity":"ERROR","container_name":"eabe8281b9a3","log":"SERIAL_INT Connection Failed: ENOENT : No such file or directory @ rb_sysopen - /dev/ttyACM0"}
{"time":1649267727484276968,"@timestamp":"2022-04-06T17:55:27.484+00:00","severity":"ERROR","container_name":"eabe8281b9a3","log":"ENOENT : No such file or directory @ rb_sysopen - /dev/ttyACM0\n/cosmos/lib/cosmos/io/posix_serial_driver.rb:55:in initialize'\n/cosmos/lib/cosmos/io/posix_serial_driver.rb:55:in open'\n/cosmos/lib/cosmos/io/posix_serial_driver.rb:55:in initialize'\n/cosmos/lib/cosmos/io/serial_driver.rb:67:in new'\n/cosmos/lib/cosmos/io/serial_driver.rb:67:in initialize'\n/cosmos/lib/cosmos/streams/serial_stream.rb:74:in new'\n/cosmos/lib/cosmos/streams/serial_stream.rb:74:in initialize'\n/cosmos/lib/cosmos/interfaces/serial_interface.rb:68:in new'\n/cosmos/lib/cosmos/interfaces/serial_interface.rb:68:in connect'\n/cosmos/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb:272:in connect'\n/cosmos/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb:79:in block (2 levels) in start'\n/cosmos/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb:77:in synchronize'\n/cosmos/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb:77:in `block in start'"}

@ghost
Copy link

ghost commented Apr 6, 2022

Can't use cosmos-control.sh cosmos cause that still runs in a container, not on the host system

@ghost
Copy link

ghost commented Apr 6, 2022

closing this ticket. See #1508

@ghost ghost closed this as completed Apr 6, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant