Upcoming Games

(UTC times)


Full list
Add a game

Upcoming Events

No events to display

Interface Gateway Help Requested

You are here: Home > Forum > Customising SimSig > Interface Gateway > Interface Gateway Help Requested

Page 1 of 3

Interface Gateway Broken 06/10/2018 at 20:04 #112492
SamTDS
Avatar
153 posts
Hey. Reading through the wiki I came across the interface gateway and had a look. It was intresting seeing the posibility of recieving the data feed. I looked in the example at the other pieces in the repository and found out that you are able to send commands to control sections of the sim itself, thus proving a great potential project to make a mock up signal board controling the sim through the stomp client. Today i have tried to go with the basic reading the data feed and i have encountered numerous random errors. The program fails to connect with the correct ports and ip set however SimSig is throwing an error saying access violation.
SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Log in to reply
Interface Gateway Broken 06/10/2018 at 20:10 #112493
headshot119
Avatar
4869 posts
I'd be tempted to say it's more an issue with the code you are using to connect, than with the interface gateway itself.

It worked fine the last time I used it.

"Passengers for New Lane, should be seated in the rear coach of the train " - Opinions are my own and not those of my employer
Log in to reply
Interface Gateway Broken 06/10/2018 at 20:14 #112494
SamTDS
Avatar
153 posts
i am using latest stomp.py version installed through pip and running your script through cmd. i also tried running stomp.py directly in the command line interface with same problem. copy of code as attached
Post has attachments. Log in to view them.
SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Log in to reply
Interface Gateway Broken 06/10/2018 at 20:17 #112495
headshot119
Avatar
4869 posts
I'm not in a position to do any debugging of code for a few days.

My client however is working fine, though it's written in Java not Python.

I'll have a look when I can.

"Passengers for New Lane, should be seated in the rear coach of the train " - Opinions are my own and not those of my employer
Log in to reply
The following user said thank you: SamTDS
Interface Gateway Broken 06/10/2018 at 20:22 #112496
SamTDS
Avatar
153 posts
roger, thanks in advance. It would probably be a good idea to learn java and get using your current client and work from there.
SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Log in to reply
Interface Gateway Broken 06/10/2018 at 20:29 #112497
GeoffM
Avatar
6376 posts
Online
I'm not familiar with Python I'm afraid. It hasn't changed for quite a while and as Karl says it works on test clients. Granted SimSig should not throw an access violation so I'd be interested to work out how that is being generated.
SimSig Boss
Log in to reply
Interface Gateway Broken 06/10/2018 at 20:55 #112498
SamTDS
Avatar
153 posts
GeoffM in post 112497 said:
I'm not familiar with Python I'm afraid. It hasn't changed for quite a while and as Karl says it works on test clients. Granted SimSig should not throw an access violation so I'd be interested to work out how that is being generated.
here is an image of the error message in full. i was trying brigton earlier and this is the same with roysten now


Post has attachments. Log in to view them.
SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Log in to reply
Interface Gateway Broken 06/10/2018 at 23:12 #112499
headshot119
Avatar
4869 posts
Right...

So I've just got home and run your script on my PC, and it just works out of the box on Aston, North Wales Coast, and Brighton.

I would suggest it's an issue with whichever stomp library you have downloaded.

"Passengers for New Lane, should be seated in the rear coach of the train " - Opinions are my own and not those of my employer
Log in to reply
Interface Gateway Broken 06/10/2018 at 23:33 #112500
SamTDS
Avatar
153 posts
hmm, most likely my python install is throroughly screwed. as for where i got the libray i had went directly from the link in the readme which was https://pypi.org/project/stomp.py/ and ran the install command provided. What could possibly be happening is you may have an older version of the library which may behave differently and be called differently. doing the command python -m stomp --version gives me the version number 4.1.21

Its almost midnight here so il probably experiment a bit tomorrow at trying to get it to work.

SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Log in to reply
Interface Gateway Broken 07/10/2018 at 07:08 #112505
GeoffM
Avatar
6376 posts
Online
Again, I'm a bit rusty on this but the "Expecting CONNECT" message is because SimSig is not seeing the verb "CONNECT" with the key/value of "accept-version" and "1.1". Yet the Python code (which I'm not familiar with) appears to send that, and Karl says it works. So I'm confused. The only thing that stands out for me is the body='accept-version:1.1' which reads to me as the body, not the header text.

As if it's sending:
CONNECT

otherbodytext
accept-version:1.1
^@

Instead of:
CONNECT
accept-version:1.1

otherbodytext
^@

(the double carriage return signifies the end of headers and the start of the body)

Maybe it's as simple as:
conn.start()
conn.connect()
conn.subscribe(etc)

(from https://stackoverflow.com/questions/6234630/activemq-how-to-configure-to-work-with-stomp-in-python )

SimSig Boss
Last edited: 07/10/2018 at 07:17 by GeoffM
Reason: None given

Log in to reply
Interface Gateway Broken 07/10/2018 at 13:50 #112513
SamTDS
Avatar
153 posts
GeoffM in post 112505 said:
Again, I'm a bit rusty on this but the "Expecting CONNECT" message is because SimSig is not seeing the verb "CONNECT" with the key/value of "accept-version" and "1.1". Yet the Python code (which I'm not familiar with) appears to send that, and Karl says it works. So I'm confused. The only thing that stands out for me is the body='accept-version:1.1' which reads to me as the body, not the header text.

As if it's sending:
CONNECT

otherbodytext
accept-version:1.1
^@

Instead of:
CONNECT
accept-version:1.1

otherbodytext
^@

(the double carriage return signifies the end of headers and the start of the body)

Maybe it's as simple as:
conn.start()
conn.connect()
conn.subscribe(etc)

(from https://stackoverflow.com/questions/6234630/activemq-how-to-configure-to-work-with-stomp-in-python )
probably is what you say at the end. il do some testing from scratch and get back to you how it goes. Il also do a clean install of python and start from there

SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Last edited: 07/10/2018 at 13:54 by SamTDS
Reason: None given

Log in to reply
Interface Gateway Broken 07/10/2018 at 15:33 #112514
SamTDS
Avatar
153 posts
I have no idea what is going on, im attempting to watch the traffic in order to find out what's happening. I dont know the protocol to that depth as much but i think im doing all the right commands but the library isnt sending the verb connect which SimSig is wanting. It sends everything else but not CONNECT. As attached is the exact code i ran in the python shell and the localhost network traffic pcap file. Wireshark is able to open it up fine and can see where each try is by the grey space. For now i am going to wait and try to figure it out later trying different libraries and languages monitoring what they give on wireshark.
Post has attachments. Log in to view them.
SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Log in to reply
Interface Gateway Broken 07/10/2018 at 17:51 #112518
Zoe
Avatar
252 posts
It looks like your client is sending a STOMP frame (introduced in STOMP 1.1) rather than a CONNECT frame. I have just tried connecting to a sim using a STOMP frame and get the "Expecting CONNECT frame" error so it seems that this is not supported by SimSig.
Last edited: 07/10/2018 at 17:54 by Zoe
Reason: None given

Log in to reply
Interface Gateway Broken 07/10/2018 at 18:44 #112520
SamTDS
Avatar
153 posts
its likely we have a later version of the library than others. We will have to wait for headshot119 to see if that is the case. If we know the working version number then we can install the older versions
SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Log in to reply
Interface Gateway Broken 07/10/2018 at 19:13 #112522
Zoe
Avatar
252 posts
SamTDS in post 112520 said:
its likely we have a later version of the library than others. We will have to wait for headshot119 to see if that is the case. If we know the working version number then we can install the older versions

I'm not using any library, I just tried sending a STOMP frame using netcat and this resulted in the "Expecting CONNECT frame" error, suggesting that SimSig does not support STOMP frames (the STOMP 1.1 specification only says that servers SHOULD handle a STOMP frame in the same was as a CONNECT frame, it does not say that they MUST do so). Sending a CONNECT frame works fine.

Last edited: 07/10/2018 at 19:17 by Zoe
Reason: None given

Log in to reply
Interface Gateway Help Requested 13/10/2018 at 22:23 #112612
belly buster
Avatar
368 posts
Likewise I tried it using both python 2.7 and 3.7 venvs and I got the same access violation and no response from the gateway.
Log in to reply
Interface Gateway Help Requested 14/10/2018 at 19:03 #112626
SamTDS
Avatar
153 posts
belly buster in post 112612 said:
Likewise I tried it using both python 2.7 and 3.7 venvs and I got the same access violation and no response from the gateway.
using the stompest library instead i am able to conenct and recive just trying to parse it now. this library has 1 problem with the subscribe command not including ID but i send a manual frame to solve that.

Will keep updated on how it goes and get a working version for everyone

edit: added screenshot of my current output result

http://prntscr.com/l60b2q

Post has attachments. Log in to view them.
SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Last edited: 14/10/2018 at 19:10 by SamTDS
Reason: None given

Log in to reply
Interface Gateway Help Requested 14/10/2018 at 20:04 #112629
SamTDS
Avatar
153 posts
Quote:
from stompest.config import StompConfig
from stompest.protocol import StompSpec, frame
from stompest.sync import Stomp

CONFIG = StompConfig('tcp://localhost:51515', version=StompSpec.VERSION_1_1)
QUEUE = '/topic/TD_ALL_SIG_AREA'

if __name__ == '__main__':
client = Stomp(CONFIG)
client.connect()
# client.subscribe(QUEUE, {StompSpec.ACK_HEADER: StompSpec.ACK_CLIENT_INDIVIDUAL})
a = frame.StompFrame(command='SUBSCRIBE', rawHeaders=[('id', '0'), ('destination', '/topic/TD_ALL_SIG_AREA'),('ack', 'auto')])
client.sendFrame(a)
while True:
frame = client.receiveFrame()
print(dict(frame))
client.disconnect()
That is the working code giving the raw messages out, il work on making it more readable in the next couple of days. For the library to get it all you have to do is
Quote:
pip install stompest
in the command line. The erroneous subscribe command has been left in hashed out as it does not include the needed id field that the 1.1 version requires.

SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Last edited: 14/10/2018 at 20:04 by SamTDS
Reason: None given

Log in to reply
The following user said thank you: DonRiver
Interface Gateway Help Requested 31/01/2019 at 18:35 #115234
SamTDS
Avatar
153 posts
Its been a while since work on this has been done due to cost to produce a full panel for even Royston. Tonight I have had the idea of instead of doing every signal and berth, do just the approach and last sent berths alongside the slot flags. This way looking at the physical panel will give a quick idea of what's approaching and slot statuses. This means a panel could be done for under £50. Id love to hear what you think. If I can find a pcb design software that works well then I might even be able to have a prototype of Royston at the Birmingham meet.
SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Log in to reply
The following user said thank you: ajax103
Interface Gateway Help Requested 18/02/2019 at 16:51 #115842
ajax103
Avatar
1120 posts
That would be interesting to see as atm it does come across as rather complicated sounding so seeing it being demo would help me for one to understand the process.
Log in to reply
Interface Gateway Help Requested 22/03/2019 at 01:36 #116520
DonRiver
Avatar
166 posts
Thanks very much Sam - I could get your stompest example to work!

Would suggest `print frame.body` rather than `print(dict(frame))` as `frame.body` gives clean json while `dict` gives… I'm not sure what exactly?

I'm trying and failing to pipe the stompest example into jq so I can format and filter the json - but the problem's probably my inexpertise with bash.

Short of building an entire NX panel (nice as that would be) I'd like to make something to help me manage trains approaching level crossings. Got North-East Scotland in mind particularly here.

Stage 1 is to write a jq filter which presents a console message when specific track sections/berths become occupied. This can run in the console on the second monitor.

Stage 2 would be a small hardware panel which indicate specific track circuits with LEDs - and if it could be wrangled, also show the status of the crossings and with hardware inputs to control them?

Stage 3 would be a scaled-down NX panel covering some manageable section of the simulation. Strips of addressable RGB LEDs might be a simple and cheap way of representing track occupancy and route selection in bulk.

Quite excited by the input control on Headshot119's Github - connecting as a SimSig client rather than to the interface. Might it be possible to get level crossing status out that way?

(named for the one in Tasmania, not in Russia)
Log in to reply
Interface Gateway Help Requested 22/03/2019 at 02:53 #116522
GeoffM
Avatar
6376 posts
Online
DonRiver in post 116520 said:
Quite excited by the input control on Headshot119's Github - connecting as a SimSig client rather than to the interface. Might it be possible to get level crossing status out that way?
It's great to see the interest in this. I would caution against using the client interface instead of the Gateway as the former uses indexes for objects and compressed fields, which can change between different versions of the same sim, whereas the Gateway uses names (human friendly as well as computer friendly). IIRC there was a slight change to the protocol just last week for clients.

You can also ask for extra things in the Gateway - usually a relatively simple task for us.

SimSig Boss
Log in to reply
Interface Gateway Help Requested 22/03/2019 at 12:54 #116545
pedroathome
Avatar
915 posts
Online
GeoffM in post 116522 said:
DonRiver in post 116520 said:
Quite excited by the input control on Headshot119's Github - connecting as a SimSig client rather than to the interface. Might it be possible to get level crossing status out that way?
It's great to see the interest in this. I would caution against using the client interface instead of the Gateway as the former uses indexes for objects and compressed fields, which can change between different versions of the same sim, whereas the Gateway uses names (human friendly as well as computer friendly). IIRC there was a slight change to the protocol just last week for clients.

You can also ask for extra things in the Gateway - usually a relatively simple task for us.
And there was another change a while back with the client interface which changed how this worked, making what I believe is on GitHub no longer work

====EDit====
Re-reading what Geoff has put, I wonder if I'm thinking of the same change

Last edited: 22/03/2019 at 12:55 by pedroathome
Reason: None given

Log in to reply
Interface Gateway Help Requested 22/03/2019 at 15:54 #116547
SamTDS
Avatar
153 posts
DonRiver in post 116520 said:
Thanks very much Sam - I could get your stompest example to work!

Would suggest `print frame.body` rather than `print(dict(frame))` as `frame.body` gives clean json while `dict` gives… I'm not sure what exactly?

I'm trying and failing to pipe the stompest example into jq so I can format and filter the json - but the problem's probably my inexpertise with bash.

Short of building an entire NX panel (nice as that would be) I'd like to make something to help me manage trains approaching level crossings. Got North-East Scotland in mind particularly here.

Stage 1 is to write a jq filter which presents a console message when specific track sections/berths become occupied. This can run in the console on the second monitor.

Stage 2 would be a small hardware panel which indicate specific track circuits with LEDs - and if it could be wrangled, also show the status of the crossings and with hardware inputs to control them?

Stage 3 would be a scaled-down NX panel covering some manageable section of the simulation. Strips of addressable RGB LEDs might be a simple and cheap way of representing track occupancy and route selection in bulk.

Quite excited by the input control on Headshot119's Github - connecting as a SimSig client rather than to the interface. Might it be possible to get level crossing status out that way?
It has indeed been quite some time since ive worked on this but luckily still have the working code. What Dict does is display it as a Dictionary array where I can just request for words such as obj_type.

Unfortunatly I haven't made any progress on the electronics side as currently we are finding it difficult to get decent free electronic design software. It is nice however to see the interest being brought in. I could likely make crossing status LEDs relatively simply.

SamTDS - STDS | My comments are my opinions and interpretations and do not reflect on the wonderfull SimSig team. I am in no way part of the team.
Log in to reply
Interface Gateway Help Requested 22/03/2019 at 15:55 #116548
GeoffM
Avatar
6376 posts
Online
My vision for opening up the Gateway was so people could rig up some customer information screens or something. Didn't happen! Always the way - you design something for some purpose, but then somebody comes along with better ideas like interfacing with panels!
SimSig Boss
Log in to reply