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

Multiple Battery Support #8

Closed
peterberbec opened this issue Mar 5, 2018 · 30 comments
Closed

Multiple Battery Support #8

peterberbec opened this issue Mar 5, 2018 · 30 comments
Labels
enhancement New feature or request

Comments

@peterberbec
Copy link

I use a Lenovo x240 and that entire series of laptop has two batteries.

@transistor1 transistor1 added the enhancement New feature or request label Mar 5, 2018
@transistor1
Copy link
Collaborator

I'm on a Surface Pro & have never owned a laptop with more than one battery, so I'll need your knowledge to help.

In your native battery manager, how is the battery status displayed (e.g. are there two battery icons, or does the power meter show the combination of the two batteries' total charge remaining)?

@peterberbec
Copy link
Author

Single battery icon in the system tray:
bat1
Two batteries if expanded:
bat2
bat3

Let me know how i can help.

@peterberbec
Copy link
Author

If there is some test program you want me to run, I would be more than willing. Something to check the battery API and send you debug logs.

@transistor1
Copy link
Collaborator

It would help me if you can post the output to the following PowerShell script:

Get-WmiObject -query "Select * from win32_Battery" 

@transistor1
Copy link
Collaborator

Make sure you remove any personal info before posting (computer name etc)

@peterberbec
Copy link
Author

__CLASS                     : Win32_Battery
__SUPERCLASS                : CIM_Battery
__DYNASTY                   : CIM_ManagedSystemElement
__RELPATH                   : Win32_Battery.DeviceID="11241SANYO45N1773"
__PROPERTY_COUNT            : 33
__DERIVATION                : {CIM_Battery, CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER                    : LAPPY2010
__NAMESPACE                 : root\cimv2
__PATH                      : \\LAPPY2010\root\cimv2:Win32_Battery.DeviceID="11241SANYO45N1773"
Availability                : 
BatteryRechargeTime         : 
BatteryStatus               : 
Caption                     : Internal Battery
Chemistry                   : 6
ConfigManagerErrorCode      : 
ConfigManagerUserConfig     : 
CreationClassName           : Win32_Battery
Description                 : Internal Battery
DesignCapacity              : 
DesignVoltage               : 12303
DeviceID                    : 11241SANYO45N1773
ErrorCleared                : 
ErrorDescription            : 
EstimatedChargeRemaining    : 99
EstimatedRunTime            : 71582788
ExpectedBatteryLife         : 
ExpectedLife                : 
FullChargeCapacity          : 
InstallDate                 : 
LastErrorCode               : 
MaxRechargeTime             : 
Name                        : 45N1773
PNPDeviceID                 : 
PowerManagementCapabilities : {1}
PowerManagementSupported    : False
SmartBatteryVersion         : 
Status                      : 
StatusInfo                  : 
SystemCreationClassName     : Win32_ComputerSystem
SystemName                  : LAPPY2010
TimeOnBattery               : 
TimeToFullCharge            : 
PSComputerName              : LAPPY2010

__GENUS                     : 2
__CLASS                     : Win32_Battery
__SUPERCLASS                : CIM_Battery
__DYNASTY                   : CIM_ManagedSystemElement
__RELPATH                   : Win32_Battery.DeviceID="17403LGC45N1127"
__PROPERTY_COUNT            : 33
__DERIVATION                : {CIM_Battery, CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER                    : LAPPY2010
__NAMESPACE                 : root\cimv2
__PATH                      : \\LAPPY2010\root\cimv2:Win32_Battery.DeviceID="17403LGC45N1127"
Availability                : 3
BatteryRechargeTime         : 
BatteryStatus               : 1
Caption                     : Internal Battery
Chemistry                   : 6
ConfigManagerErrorCode      : 
ConfigManagerUserConfig     : 
CreationClassName           : Win32_Battery
Description                 : Internal Battery
DesignCapacity              : 
DesignVoltage               : 11149
DeviceID                    : 17403LGC45N1127
ErrorCleared                : 
ErrorDescription            : 
EstimatedChargeRemaining    : 48
EstimatedRunTime            : 55
ExpectedBatteryLife         : 
ExpectedLife                : 
FullChargeCapacity          : 
InstallDate                 : 
LastErrorCode               : 
MaxRechargeTime             : 
Name                        : 45N1127
PNPDeviceID                 : 
PowerManagementCapabilities : {1}
PowerManagementSupported    : False
SmartBatteryVersion         : 
Status                      : OK
StatusInfo                  : 
SystemCreationClassName     : Win32_ComputerSystem
SystemName                  : LAPPY2010
TimeOnBattery               : 
TimeToFullCharge            : 
PSComputerName              : LAPPY2010

@transistor1
Copy link
Collaborator

Great thanks!

@transistor1
Copy link
Collaborator

And what does your total battery percentage say right now? Want to see if I can replicate it using the data above.

@transistor1
Copy link
Collaborator

Nvm I think I can just do (batt1+batt2)/200

transistor1 added a commit that referenced this issue Mar 6, 2018
@transistor1
Copy link
Collaborator

Please try release v1.0.1 and let me know if it works for you.

@peterberbec
Copy link
Author

As of right now, it does not. It crashes MSTSC.exe. I will try rebooting and test again.

@transistor1
Copy link
Collaborator

Also make sure that the old version of the RDS_Server_TrayApp_BattMon.exe isn't still running in your
detached terminal server session. You can temporarily move or rename the client add-in file to get it to connect if you need to terminate that exe first.

@peterberbec
Copy link
Author

Renaming and rebooting the server machine too.

@peterberbec
Copy link
Author

Nope. It crashes even after both machines are rebooted. Any logs I can send?

@peterberbec
Copy link
Author

- <System>
  <Provider Name="Windows Error Reporting" /> 
  <EventID Qualifiers="0">1001</EventID> 
  <Level>4</Level> 
  <Task>0</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2018-03-06T02:40:53.652294500Z" /> 
  <EventRecordID>30097</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>Lappy2010</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>1203824740160883411</Data> 
  <Data>5</Data> 
  <Data>CLR20r3</Data> 
  <Data>Not available</Data> 
  <Data>0</Data> 
  <Data>mstsc.exe</Data> 
  <Data>10.0.16299.15</Data> 
  <Data>3a40081f</Data> 
  <Data>RDS_Client_Addin_BattMon</Data> 
  <Data>1.0.0.0</Data> 
  <Data>5a9df887</Data> 
  <Data>2a</Data> 
  <Data>20</Data> 
  <Data>System.NullReferenceException</Data> 
  <Data /> 
  <Data>\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAC5D.tmp.mdmp \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERB3E1.tmp.WERInternalMetadata.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERB3EF.tmp.csv \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERB42E.tmp.txt \\?\C:\Users\Peter Berbec\AppData\Local\Temp\WERC17F.tmp.appcompat.txt \\?\C:\Users\Peter Berbec\AppData\Local\Temp\WERC1AE.tmp.WERDataCollectionStatus.txt</Data> 
  <Data>C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_mstsc.exe_40dce5c8e820f6eec814409721988ad8237b26f4_2d2465bf_0f95c1e9</Data> 
  <Data /> 
  <Data>0</Data> 
  <Data>cced80bb-9f01-4488-bc77-710bb6c172cc</Data> 
  <Data>2147487752</Data> 
  <Data>7f4d22beda2c3bd7f0b4d839191dcad3</Data> 
  </EventData>
  </Event>

@transistor1
Copy link
Collaborator

Hmm. I'm still trying to get the logger to work, but check Event Viewer->Application log anyway. Maybe it logged something useful.

Ah -- looks like you beat me to it.

Let me give you a debug build that might give more detail (like the line # it's crashing on). That log is only telling me that it's a NullReferenceException, but not where.

@transistor1
Copy link
Collaborator

Try these -- make sure you keep the .pdb files in the same folder; they will provide the line # debugging information.

Client (v1.0.1 Debug).zip
Server (v1.0.1 Debug).zip

@transistor1
Copy link
Collaborator

Even better -- this version has logging enabled on the client side. It should capture the exception you're getting with the stack trace. Again, please be sure to keep the .pdb file in the same folder as the DLL.

Client (v1.0.1.2 Debug).zip
Server (v1.0.1.2 Debug).zip

@peterberbec
Copy link
Author

Is the new information still in the event log?

- <System>
  <Provider Name="Application Error" /> 
  <EventID Qualifiers="0">1000</EventID> 
  <Level>2</Level> 
  <Task>100</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2018-03-06T03:30:51.244440700Z" /> 
  <EventRecordID>30233</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>Lappy2010</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>mstsc.exe</Data> 
  <Data>10.0.16299.15</Data> 
  <Data>3a40081f</Data> 
  <Data>unknown</Data> 
  <Data>0.0.0.0</Data> 
  <Data>00000000</Data> 
  <Data>c0000005</Data> 
  <Data>00007ffb0c193629</Data> 
  <Data>36b4</Data> 
  <Data>01d3b4fb6ebb9a9a</Data> 
  <Data>C:\Windows\system32\mstsc.exe</Data> 
  <Data>unknown</Data> 
  <Data>89bfb725-a930-4e09-afe4-3840451c4c99</Data> 
  <Data /> 
  <Data /> 
  </EventData>
  </Event>

@peterberbec
Copy link
Author

- <System>
  <Provider Name=".NET Runtime" /> 
  <EventID Qualifiers="0">1026</EventID> 
  <Level>2</Level> 
  <Task>0</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2018-03-06T03:30:49.916300500Z" /> 
  <EventRecordID>30232</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>Lappy2010</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>Application: mstsc.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException at FieldEffect.Classes.Win32BatteryManagementObjectSearcher.GetAllBatteries() at FieldEffect.Models.BatteryDataReporter._clientAddIn_DataChannelEvent(System.Object, FieldEffect.VCL.Client.DataChannelEventArgs) at FieldEffect.VCL.Client.RdpClientVirtualChannel.OnDataChannelEvent(FieldEffect.VCL.Client.DataChannelEventArgs) at FieldEffect.VCL.Client.RdpClientVirtualChannel.VirtualChannelOpenEvent(Int32, FieldEffect.VCL.Client.WtsApi32.ChannelEvents, Byte[], Int32, UInt32, FieldEffect.VCL.Client.WtsApi32.ChannelFlags)</Data> 
  </EventData>
  </Event>

@peterberbec
Copy link
Author

Those were from 1.0.1 debug. loading 1.0.2 now

@peterberbec
Copy link
Author

1.0.1.2:

- <System>
  <Provider Name="Windows Error Reporting" /> 
  <EventID Qualifiers="0">1001</EventID> 
  <Level>4</Level> 
  <Task>0</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2018-03-06T03:38:22.594850200Z" /> 
  <EventRecordID>30242</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>Lappy2010</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>1833787917323518067</Data> 
  <Data>5</Data> 
  <Data>CLR20r3</Data> 
  <Data>Not available</Data> 
  <Data>0</Data> 
  <Data>mstsc.exe</Data> 
  <Data>10.0.16299.15</Data> 
  <Data>3a40081f</Data> 
  <Data>RDS_Client_Addin_BattMon</Data> 
  <Data>1.0.1.0</Data> 
  <Data>5a9e0ad3</Data> 
  <Data>2b</Data> 
  <Data>68</Data> 
  <Data>System.NullReferenceException</Data> 
  <Data /> 
  <Data>\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2B8A.tmp.mdmp \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER34A4.tmp.WERInternalMetadata.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER34B1.tmp.csv \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER34F1.tmp.txt \\?\C:\Users\Peter Berbec\AppData\Local\Temp\WER4280.tmp.appcompat.txt \\?\C:\Users\Peter Berbec\AppData\Local\Temp\WER42A0.tmp.WERDataCollectionStatus.txt</Data> 
  <Data>C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_mstsc.exe_3edcc19b72aba3b85e9781e9c4bda1e80e62e59_2d2465bf_15dc42da</Data> 
  <Data /> 
  <Data>0</Data> 
  <Data>ffe79c66-7891-4e97-a06e-aa69ea2fc2f9</Data> 
  <Data>2147487752</Data> 
  <Data>9792ade44c9760f5f972ec651d78c073</Data> 
  </EventData>
  </Event>

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Application Error" /> 
  <EventID Qualifiers="0">1000</EventID> 
  <Level>2</Level> 
  <Task>100</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2018-03-06T03:38:16.126011400Z" /> 
  <EventRecordID>30241</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>Lappy2010</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>mstsc.exe</Data> 
  <Data>10.0.16299.15</Data> 
  <Data>3a40081f</Data> 
  <Data>unknown</Data> 
  <Data>0.0.0.0</Data> 
  <Data>00000000</Data> 
  <Data>c0000005</Data> 
  <Data>00007ffb0c14bff9</Data> 
  <Data>e0c</Data> 
  <Data>01d3b4fc844c4599</Data> 
  <Data>C:\Windows\system32\mstsc.exe</Data> 
  <Data>unknown</Data> 
  <Data>ffe79c66-7891-4e97-a06e-aa69ea2fc2f9</Data> 
  <Data /> 
  <Data /> 
  </EventData>
  </Event>


- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name=".NET Runtime" /> 
  <EventID Qualifiers="0">1026</EventID> 
  <Level>2</Level> 
  <Task>0</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2018-03-06T03:38:14.704141900Z" /> 
  <EventRecordID>30240</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>Lappy2010</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>Application: mstsc.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException at FieldEffect.Classes.Win32BatteryManagementObjectSearcher.GetAllBatteries() at FieldEffect.Models.BatteryDataReporter._clientAddIn_DataChannelEvent(System.Object, FieldEffect.VCL.Client.DataChannelEventArgs) at FieldEffect.VCL.Client.RdpClientVirtualChannel.OnDataChannelEvent(FieldEffect.VCL.Client.DataChannelEventArgs) at FieldEffect.VCL.Client.RdpClientVirtualChannel.VirtualChannelOpenEvent(Int32, FieldEffect.VCL.Client.WtsApi32.ChannelEvents, Byte[], Int32, UInt32, FieldEffect.VCL.Client.WtsApi32.ChannelFlags)</Data> 
  </EventData>
  </Event>

@peterberbec
Copy link
Author

The referenced wer file. Hope this doesn't contain anything too bad.

Report.wer.txt

@peterberbec
Copy link
Author

BTW: You're the best. Just thought the world should know that.

@transistor1
Copy link
Collaborator

Can you please try this version & see if the crash goes away?

Client (v1.0.1.3 Debug).zip
Server (v1.0.1.3 Debug).zip

@peterberbec
Copy link
Author

Not crashing anymore.

batmon

@transistor1
Copy link
Collaborator

Well, it's a start... 😄

@peterberbec
Copy link
Author

:)

@transistor1
Copy link
Collaborator

@peterberbec
Copy link
Author

I rolled back to v1.0.0 on client and server, and it still functioned fine. It seems:

  1. all the juggling hasn't broken things irredemably
  2. DLLs can be changed on the fly. Once MSTSC crashes, if I overwrite the dll file with another version, that one loads. Same with the exe on the server. Quitting and starting a new one leads to version match.

This will speed up debugging because I don't have to keep rebooting both machines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants