2

UPS is Soltec Apa-650 with "megatec battery driver". Even being in the device manager battery area, it doesn't appear in the Win32_Battery.

Status is available with Upsilon 2000 software (remaining, temperature, etc...). But now I need to read these values from a C# program First idea: After seeing the payload with Wireshark, I want to replay it with c#. Any Idea?

For example, I tried pinvoke

deviceHandle = Kernel32.CreateFile(deviceInstancePath, 0, Constants.FileShareRead | Constants.FileShareWrite, IntPtr.Zero, Constants.OpenExisting, 0, 0); => The handle is ok

var success = Kernel32.WriteFile( deviceInformation.WriteHandle, outputReportBuffer, outputReportBuffer.Length, ref numberOfBytesWritten, IntPtr.Zero); => The success returns false

Does anybody know where I can find the failing explanation?

Any help would be appreciated (sorry for my English, I'm a french guy)

Edit

Thank's to aja here is the answer about the failing explaination

Win32Exception a = new Win32Exception(Marshal.GetLastWin32Error());
Console.WriteLine(a.Message)
axxel95
  • 41
  • 4
  • Calling Marshall. GetLastWin32Error might be worth trying - as explained here: https://stackoverflow.com/questions/17918266/winapi-getlasterror-vs-marshal-getlastwin32error – aja Dec 02 '20 at 19:38
  • Thank you very much aja. I'm gonna try that. – axxel95 Dec 04 '20 at 09:58
  • In my case I just listened to the TCP/UDP traffic but could not send commands to the UPS. `tcp.port == 2570 connect as a client and get data`, `tcp.port == 8652 read the data from the sms server` and `udp.port == 11541 udp data` – Jonas Jun 11 '23 at 04:45

0 Answers0