Click here to Skip to main content
15,921,250 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have made a little progress:
<pre lang="PowerShell">
Add-Type -Path "C:\myDlls\BACNet\net40\BACnet.dll"
Add-Type -AssemblyName System
Add-Type -AssemblyName System.Linq
Add-Type -AssemblyName System.Threading

[System.IO.BACnet.BacnetIpUdpProtocolTransport]$Transport = New-Object System.IO.BACnet.BacnetIpUdpProtocolTransport -ArgumentList 0xBAC0,$false,$false,"1472",""
[System.IO.BACnet.BacnetClient]$BNTclient = New-Object System.IO.BACnet.BacnetClient -ArgumentList $Transport
[System.IO.BACnet.BacnetObjectTypes]$BacnetObj = [System.IO.BACnet.BacnetObjectTypes]::OBJECT_ANALOG_INPUT
[System.IO.BACnet.BacnetObjectId]$BacnetOID = New-Object System.IO.BACnet.BacnetObjectId -ArgumentList $BacnetObj,10
[System.IO.BACnet.BacnetPropertyIds]$BacnetPropID = [System.IO.BACnet.BacnetPropertyIds]::PROP_PRESENT_VALUE

$noScalarValue = [System.Collections.Generic.List[System.IO.BACnet.BacnetValue]]@()
$Result = $BNTclient.ReadPropertyRequest($device_id, $objectId, $propertyId, [ref]$noScalarValue)

the last line of code where I define
isn't quite right

Cannot find an overload for "ReadPropertyRequest" and the argument count: "4".
At C:\Users\admin\Desktop\BACNet\BACNetRead2.ps1:31 char:1

What I have tried:

i've tried looking at the examples
IList<BacnetValue> NoScalarValue;
if (bacnet_client.ReadPropertyRequest(adr, BacnetObjet, Propriete, out NoScalarValue)==false)

from here BACnet.Examples/BasicReadWrite/Program.cs at master · ela-compil/BACnet.Examples · GitHub[^]

from what i can tell, its like the "if" statement of the example is actually dumping values into the IList
Updated 14-Jun-24 1:27am
Richard Deeming 7-May-24 4:41am    
There doesn't seem to be much (if any) documentation, so you're probably going to have to dig into the source code[^] - that shows that the Start method of the BacnetClient class has no parameters.

Rather than randomly changing code based on partial summaries of the error message, actually read the error message - it will usually tell you precisely what the problem is.

If you still don't understand the error, then post the full error message here, or ask on the GitHub project you're using.

Look at the error message, it's pretty explicit:
Cannot find an overload for "ReadPropertyRequest" and the argument count: "4".
At C:\Users\admin\Desktop\BACNet\BACNetRead2.ps1:31 char:1
IOt's saying that the problem is line 31 in the file BACNetRead2.ps1 and the problem is that the object in $BNTclient does not have a method called ReadPropertyRequest which accepts exactly 4 parameters with those signatures. It may have overloads that have 0, 1, 2, 3, or 5 + - but there is nothing that takes 4 that match the type of variables you are trying to call it with.

Now, I know nothing about ICESoft or it's products, but I'd either start here: BACnet - Part 2: Different ways of reading values using BACnet[^] or follow the "Contact Us" link at the bottom of that page to speak to people who should know their product (and presumably supply support assuming you paid for the product in the first place).

The first place to start is always the error message - it give you a lot of information if you understand how to read it: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^]
Share this answer
You get an exception in this call
$BNTclient.ReadPropertyRequest($device_id, $objectId, $propertyId, [ref]$noScalarValue)
The reason is, you are passing invalid arguments and there is no such method overload to satisfy it. This is the declaration of this method from the sources:
public bool ReadPropertyRequest(BacnetAddress adr, BacnetObjectId objectId, BacnetPropertyIds propertyId, out IList<BacnetValue> valueList, byte invokeId = 0, uint arrayIndex = ASN1.BACNET_ARRAY_ALL)
As you can see, first argument is of type BacnetAddress, not an integer as your are passing ($device_id). You need to pass BacnetAddress instance like one below. You provide the IP address of the device from which you want to read the object property.
var address = new BacnetAddress(BacnetAddressTypes.IP, "")
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900