-
Notifications
You must be signed in to change notification settings - Fork 98
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
New Feature: Allow bacstack client to communicate with bacnet server on same device #79
Comments
Hi @tim-view I think this is indeed a rather special use-case you have and I've never seen something like this in other BACNET projects. There are two points I would like to make:
However, I don't completely oppose the idea of introducing a new and optional parameter to have a different listener/sender port, as long as we keep the impact as small as possible. I always love PRs 😄 I would like to see something like this (code located here): var settings = {
port: options.port || 47808,
senderPort: options.senderPort || options.port || 47808,
interface: options.interface,
transport: options.transport,
broadcastAddress: options.broadcastAddress || '255.255.255.255',
adpuTimeout: options.adpuTimeout || 3000
}; What's your thought on this? Cheers |
Hello @fh1ch
Posting a reply below since email generated replies don't allow markdown.
|
Hello @fh1ch Thanks for getting back to me and thanks for the great work with the library! I definitely have a special case. I also know very little about BACNET – just enough to get my app working and to be dangerous ☺ I did find that my issue is a little common. It is related to question 15 in this FAQ: http://svn.code.sf.net/p/bacnet/code/trunk/bacnet-stack/doc/README.faq. My app/service is more like a remote or browser. The server is more common and responds to broadcast. My app is more similar to your browser and connects to one or more BACNET servers to read and write properties. I will go ahead and submit a PR. My code was basically the same as the example you sent except for I was calling it serverPort since that was what my use case was. I will change it to senderPort. I also updated the transport code to use this port when sending: (bacnet-client) var settings = {
port: options.port || 47808,
senderPort: options.senderPort || options.port || 47808,
interface: options.interface,
transport: options.transport,
broadcastAddress: options.broadcastAddress || '255.255.255.255',
adpuTimeout: options.adpuTimeout || 3000
};
var transport = settings.transport || new baTransport({
port: settings.port,
senderPort: settings.senderPort,
interface: settings.interface,
broadcastAddress: settings.broadcastAddress
}); and (bacnet-transport) self.send = function(buffer, offset, receiver) {
server.send(buffer, 0, offset, settings.senderPort, receiver);
}; If that seems right, I will submit a PR. One last question… Should I update the readme to mention this optional parameter? I don’t want to confuse people with it, but would want them to know about it. Thanks again!! |
@tim-view thanks for your reply. Regarding the FAQ entry: yes, that's indeed a common issue, which I'm also experience when using my browser / device simulator. If not started in the right order (device first), who-is won't work. I'm currently working around this for some upcoming compliance tests using Docker and it's internal networking (each container has it's own IP, see https://github.com/fh1ch/node-bacstack/blob/test/compliance-tests/docker-compose.yml). Yes, the code snippets provided by you look all-right and should pass all linter checks with ease (I would still suggest you to read the Regarding documentation: The |
I wanted to do some quick bacnet developement and had a similar issue. According to the readme from https://sourceforge.net/projects/yetanotherbacnetexplorer/: The BACnet socket at 0xBAC0 should be used for receiving broadcasts. Not to transmit anything or receive any unicasts. If you want to transmit a broadcast you use the other socket (a random port given to you by the PC) and send the broadcast to the 0xBAC0 port. After a quick look at the source this mod to bacstack\lib\transport.js seemed reasonable to allow addresses to be string ip/id or object with {address:'',port:0} with the following caveats: client.js : control methods poss issues I didn't follow up: Seemed to work with some very basic testing.
|
@tim-view @username-II Is this feature still interesting or do you already developed it? Maybe you could share your code as PR to https://github.com/BiancoRoyal/node-bacstack . I also had probles running tests on same device as the server ... |
I don't know if this is useful for everyone or is a special case for me, but I have a bacnet client I'm writing that needs to communicate with an existing bacnet server. In most cases, this new client and the existing server will be on the same device/at the same IP.
I need a way to bind the client to on UDP port and communicate with the server on the UDP port it is already bound to. If I don't do this, the client can't bind to the UDP port in use by the server and they cannont communicate with each other.
I got this working by doing two things:
I'm not a bacnet expert and am not sure if there is more that needs to be done to make complete this feature, but this change completely solves my issues.
Does anyone else need this feature?
If so, should I submit a pull request?
Is there a better name for the option I added? It makes sense for my use case, but I don't think "server_port" is the right name.
The text was updated successfully, but these errors were encountered: