FrankPfattheicher / RevolutionPi

.NET support libraries for data exchange with RevPi I/O-Modules and Gateways
GNU General Public License v3.0
9 stars 3 forks source link

SetBitValue function not working #2

Closed NSURLSession0 closed 3 years ago

NSURLSession0 commented 4 years ago

Hi!

I was just testing your framework (thank you for sharing!) and I noticed 'SetBitValue' doesn't do what I expect it to do.

When I run: piTest -s 289,0,1 It sets the bit at address 289, offset 0 to the value 1.

When I try to do the same using this framework I get the following error: PiTest.exe Error: 0 : PiControl.SetBitValue: Failed to write bit value.

The code I am using: control.SetBitValue(289, 0, true);

Any idea whether this is a bug or that I am doing something wrong?

Edit: I just noticed none of the commands seem to work. Reading and writing bits result in an error, but calling control.Reset() for example also results in a false. I guess something is broken. I already looked at PiControl.cs but it everything looks very similar to piControl.h. So it might have something to do with the application not being able to read /dev/piControl0. I am not sure.

FrankPfattheicher commented 4 years ago

Hi Maurice,

did you try sudo ?

I think it needs admin rights for access.

It is a long time since i have written this... But anyway i will help you until it works !

NSURLSession0 commented 4 years ago

Hi Frank! I forgot to mention that I indeed tried to run it with sudo. It doesn't help unfortunately. I think this issue is also the reason why controlling the LED (#1) doesn't work.

NSURLSession0 commented 4 years ago

Any news on this? :)

FrankPfattheicher commented 3 years ago

@Mauricevb now i tried PiTest.Core after moving it to netcore3.1 - works as expected.

Where comes the address "289" come from?

Did you try "PiTest -d" ? The library requires the system to be configured.

NSURLSession0 commented 3 years ago

Hi Frank! I compiled/published PiTest.Core with NetCore 3.1 as you said and the runtime 3.1 is installed on the Pi (stretch).

Running sudo ./PiTest -d prints:

Console Result (click to expand) ``` PiTest Information: 0 : RevPiLeds: Using address 0x06 Device RevPi DIO [LEFT_RIGHT] Address: 0, Type: 96 (0x60) RevPi DIO I[0000] I_1 : BIT I[0000] I_2 : BIT I[0000] I_3 : BIT I[0000] I_4 : BIT I[0000] I_5 : BIT I[0000] I_6 : BIT I[0000] I_7 : BIT I[0000] I_8 : BIT I[0000] I_9 : BIT I[0000] I_10 : BIT I[0000] I_11 : BIT I[0000] I_12 : BIT I[0000] I_13 : BIT I[0000] I_14 : BIT I[0000] I_15 : BIT I[0000] I_16 : BIT I[0002] Output_Status : WORD I[0004] Status : WORD I[0006] Counter_1 : DWORD I[0010] Counter_2 : DWORD I[0014] Counter_3 : DWORD I[0018] Counter_4 : DWORD I[0022] Counter_5 : DWORD I[0026] Counter_6 : DWORD I[0030] Counter_7 : DWORD I[0034] Counter_8 : DWORD I[0038] Counter_9 : DWORD I[0042] Counter_10 : DWORD I[0046] Counter_11 : DWORD I[0050] Counter_12 : DWORD I[0054] Counter_13 : DWORD I[0058] Counter_14 : DWORD I[0062] Counter_15 : DWORD I[0066] Counter_16 : DWORD Q[0070] O_1 : BIT Q[0070] O_2 : BIT Q[0070] O_3 : BIT Q[0070] O_4 : BIT Q[0070] O_5 : BIT Q[0070] O_6 : BIT Q[0070] O_7 : BIT Q[0070] O_8 : BIT Q[0070] O_9 : BIT Q[0070] O_10 : BIT Q[0070] O_11 : BIT Q[0070] O_12 : BIT Q[0070] O_13 : BIT Q[0070] O_14 : BIT Q[0070] O_15 : BIT Q[0070] O_16 : BIT Q[0072] PWM_1 : BYTE Q[0073] PWM_2 : BYTE Q[0074] PWM_3 : BYTE Q[0075] PWM_4 : BYTE Q[0076] PWM_5 : BYTE Q[0077] PWM_6 : BYTE Q[0078] PWM_7 : BYTE Q[0079] PWM_8 : BYTE Q[0080] PWM_9 : BYTE Q[0081] PWM_10 : BYTE Q[0082] PWM_11 : BYTE Q[0083] PWM_12 : BYTE Q[0084] PWM_13 : BYTE Q[0085] PWM_14 : BYTE Q[0086] PWM_15 : BYTE Q[0087] PWM_16 : BYTE M[0088] InputMode_1 : BYTE M[0089] InputMode_2 : BYTE M[0090] InputMode_3 : BYTE M[0091] InputMode_4 : BYTE M[0092] InputMode_5 : BYTE M[0093] InputMode_6 : BYTE M[0094] InputMode_7 : BYTE M[0095] InputMode_8 : BYTE M[0096] InputMode_9 : BYTE M[0097] InputMode_10 : BYTE M[0098] InputMode_11 : BYTE M[0099] InputMode_12 : BYTE M[0100] InputMode_13 : BYTE M[0101] InputMode_14 : BYTE M[0102] InputMode_15 : BYTE M[0103] InputMode_16 : BYTE M[0104] InputDebounce : WORD M[0106] OutputPushPull : WORD M[0108] OutputOpenLoadDetect : WORD M[0110] OutputPWMActive : WORD M[0112] OutputPWMFrequency : BYTE Device RevPi Core V1.2 [BASE] Address: 113, Type: 95 (0x5F) RevPi Core I[0000] RevPiStatus : BYTE I[0001] RevPiIOCycle : BYTE I[0002] RS485ErrorCnt : WORD I[0004] Core_Temperatur : BYTE I[0005] Core_Frequency : BYTE Q[0006] RevPiLED : BYTE Q[0007] RS485ErrorLimit1 : WORD Q[0009] RS485ErrorLimit2 : WORD Device ModbusRTU Master [VIRTUAL] Address: 124, Type: 24580 (0x6004) ModbusRTU Master Adapter I[0000] Input_Word_1 : WORD I[0002] Input_Word_2 : WORD I[0004] Input_Word_3 : WORD I[0006] Input_Word_4 : WORD I[0008] Input_Word_5 : WORD I[0010] Input_Word_6 : WORD I[0012] Input_Word_7 : WORD I[0014] Input_Word_8 : WORD I[0016] Input_Word_9 : WORD I[0018] Input_Word_10 : WORD I[0020] Input_Word_11 : WORD I[0022] Input_Word_12 : WORD I[0024] Input_Word_13 : WORD I[0026] Input_Word_14 : WORD I[0028] Input_Word_15 : WORD I[0030] Input_Word_16 : WORD I[0032] Input_Word_17 : WORD I[0034] Input_Word_18 : WORD I[0036] Input_Word_19 : WORD I[0038] Input_Word_20 : WORD I[0040] Input_Word_21 : WORD I[0042] Input_Word_22 : WORD I[0044] Input_Word_23 : WORD I[0046] Input_Word_24 : WORD I[0048] Input_Word_25 : WORD I[0050] Input_Word_26 : WORD I[0052] Input_Word_27 : WORD I[0054] Input_Word_28 : WORD I[0056] Input_Word_29 : WORD I[0058] Input_Word_30 : WORD I[0060] Input_Word_31 : WORD I[0062] Input_Word_32 : WORD I[0064] Input_Bit_1 : BIT I[0064] Input_Bit_2 : BIT I[0064] Input_Bit_3 : BIT I[0064] Input_Bit_4 : BIT I[0064] Input_Bit_5 : BIT I[0064] Input_Bit_6 : BIT I[0064] Input_Bit_7 : BIT I[0064] Input_Bit_8 : BIT I[0064] Input_Bit_9 : BIT I[0064] Input_Bit_10 : BIT I[0064] Input_Bit_11 : BIT I[0064] Input_Bit_12 : BIT I[0064] Input_Bit_13 : BIT I[0064] Input_Bit_14 : BIT I[0064] Input_Bit_15 : BIT I[0064] Input_Bit_16 : BIT I[0064] Input_Bit_17 : BIT I[0064] Input_Bit_18 : BIT I[0064] Input_Bit_19 : BIT I[0064] Input_Bit_20 : BIT I[0064] Input_Bit_21 : BIT I[0064] Input_Bit_22 : BIT I[0064] Input_Bit_23 : BIT I[0064] Input_Bit_24 : BIT I[0064] Input_Bit_25 : BIT I[0064] Input_Bit_26 : BIT I[0064] Input_Bit_27 : BIT I[0064] Input_Bit_28 : BIT I[0064] Input_Bit_29 : BIT I[0064] Input_Bit_30 : BIT I[0064] Input_Bit_31 : BIT I[0064] Input_Bit_32 : BIT I[0068] Modbus_Action_Status_1 : BYTE I[0069] Modbus_Action_Status_2 : BYTE I[0070] Modbus_Action_Status_3 : BYTE I[0071] Modbus_Action_Status_4 : BYTE I[0072] Modbus_Action_Status_5 : BYTE I[0073] Modbus_Action_Status_6 : BYTE I[0074] Modbus_Action_Status_7 : BYTE I[0075] Modbus_Action_Status_8 : BYTE I[0076] Modbus_Action_Status_9 : BYTE I[0077] Modbus_Action_Status_10 : BYTE I[0078] Modbus_Action_Status_11 : BYTE I[0079] Modbus_Action_Status_12 : BYTE I[0080] Modbus_Action_Status_13 : BYTE I[0081] Modbus_Action_Status_14 : BYTE I[0082] Modbus_Action_Status_15 : BYTE I[0083] Modbus_Action_Status_16 : BYTE I[0084] Modbus_Action_Status_17 : BYTE I[0085] Modbus_Action_Status_18 : BYTE I[0086] Modbus_Action_Status_19 : BYTE I[0087] Modbus_Action_Status_20 : BYTE I[0088] Modbus_Action_Status_21 : BYTE I[0089] Modbus_Action_Status_22 : BYTE I[0090] Modbus_Action_Status_23 : BYTE I[0091] Modbus_Action_Status_24 : BYTE I[0092] Modbus_Action_Status_25 : BYTE I[0093] Modbus_Action_Status_26 : BYTE I[0094] Modbus_Action_Status_27 : BYTE I[0095] Modbus_Action_Status_28 : BYTE I[0096] Modbus_Action_Status_29 : BYTE I[0097] Modbus_Action_Status_30 : BYTE I[0098] Modbus_Action_Status_31 : BYTE I[0099] Modbus_Action_Status_32 : BYTE I[0100] Modbus_Master_Status : BYTE Q[0101] MotorSpeed : WORD Q[0103] Output_Word_2 : WORD Q[0105] Output_Word_3 : WORD Q[0107] Output_Word_4 : WORD Q[0109] Output_Word_5 : WORD Q[0111] Output_Word_6 : WORD Q[0113] Output_Word_7 : WORD Q[0115] Output_Word_8 : WORD Q[0117] Output_Word_9 : WORD Q[0119] Output_Word_10 : WORD Q[0121] Output_Word_11 : WORD Q[0123] Output_Word_12 : WORD Q[0125] Output_Word_13 : WORD Q[0127] Output_Word_14 : WORD Q[0129] Output_Word_15 : WORD Q[0131] Output_Word_16 : WORD Q[0133] Output_Word_17 : WORD Q[0135] Output_Word_18 : WORD Q[0137] Output_Word_19 : WORD Q[0139] Output_Word_20 : WORD Q[0141] Output_Word_21 : WORD Q[0143] Output_Word_22 : WORD Q[0145] Output_Word_23 : WORD Q[0147] Output_Word_24 : WORD Q[0149] Output_Word_25 : WORD Q[0151] Output_Word_26 : WORD Q[0153] Output_Word_27 : WORD Q[0155] Output_Word_28 : WORD Q[0157] Output_Word_29 : WORD Q[0159] Output_Word_30 : WORD Q[0161] Output_Word_31 : WORD Q[0163] Output_Word_32 : WORD Q[0165] MotorStart : BIT Q[0165] MotorReverse : BIT Q[0165] Output_Bit_3 : BIT Q[0165] Output_Bit_4 : BIT Q[0165] Output_Bit_5 : BIT Q[0165] Output_Bit_6 : BIT Q[0165] Output_Bit_7 : BIT Q[0165] Output_Bit_8 : BIT Q[0165] Output_Bit_9 : BIT Q[0165] Output_Bit_10 : BIT Q[0165] Output_Bit_11 : BIT Q[0165] Output_Bit_12 : BIT Q[0165] Output_Bit_13 : BIT Q[0165] Output_Bit_14 : BIT Q[0165] Output_Bit_15 : BIT Q[0165] Output_Bit_16 : BIT Q[0165] Output_Bit_17 : BIT Q[0165] Output_Bit_18 : BIT Q[0165] Output_Bit_19 : BIT Q[0165] Output_Bit_20 : BIT Q[0165] Output_Bit_21 : BIT Q[0165] Output_Bit_22 : BIT Q[0165] Output_Bit_23 : BIT Q[0165] Output_Bit_24 : BIT Q[0165] Output_Bit_25 : BIT Q[0165] Output_Bit_26 : BIT Q[0165] Output_Bit_27 : BIT Q[0165] Output_Bit_28 : BIT Q[0165] Output_Bit_29 : BIT Q[0165] Output_Bit_30 : BIT Q[0165] Output_Bit_31 : BIT Q[0165] Output_Bit_32 : BIT Q[0169] Action_Status_Reset_1 : BIT Q[0169] Action_Status_Reset_2 : BIT Q[0169] Action_Status_Reset_3 : BIT Q[0169] Action_Status_Reset_4 : BIT Q[0169] Action_Status_Reset_5 : BIT Q[0169] Action_Status_Reset_6 : BIT Q[0169] Action_Status_Reset_7 : BIT Q[0169] Action_Status_Reset_8 : BIT Q[0169] Action_Status_Reset_9 : BIT Q[0169] Action_Status_Reset_10 : BIT Q[0169] Action_Status_Reset_11 : BIT Q[0169] Action_Status_Reset_12 : BIT Q[0169] Action_Status_Reset_13 : BIT Q[0169] Action_Status_Reset_14 : BIT Q[0169] Action_Status_Reset_15 : BIT Q[0169] Action_Status_Reset_16 : BIT Q[0169] Action_Status_Reset_17 : BIT Q[0169] Action_Status_Reset_18 : BIT Q[0169] Action_Status_Reset_19 : BIT Q[0169] Action_Status_Reset_20 : BIT Q[0169] Action_Status_Reset_21 : BIT Q[0169] Action_Status_Reset_22 : BIT Q[0169] Action_Status_Reset_23 : BIT Q[0169] Action_Status_Reset_24 : BIT Q[0169] Action_Status_Reset_25 : BIT Q[0169] Action_Status_Reset_26 : BIT Q[0169] Action_Status_Reset_27 : BIT Q[0169] Action_Status_Reset_28 : BIT Q[0169] Action_Status_Reset_29 : BIT Q[0169] Action_Status_Reset_30 : BIT Q[0169] Action_Status_Reset_31 : BIT Q[0169] Action_Status_Reset_32 : BIT Q[0173] Master_Status_Reset : BYTE M[0174] device_path : [256bits] M[0208] baud_rate : DWORD M[0212] parity : BYTE M[0213] data_bits : BYTE M[0214] stop_bits : BYTE ```

So that's working.

However, if I want to change a LED using sudo ./PiTest -y 1 r, it prints:

PiTest Information: 0 : RevPiLeds: Using address 0x06

But nothing is happening. It just prints that line and the LED stays the same.

The address 289 (my previous comment) comes from my configuration where 289 starts the motor using modbus. This is working with RevPi's PiTest but not with this framework. I assume it's the same issue as the LED not changing.

FrankPfattheicher commented 3 years ago

@Mauricevb ok, so let me ask if some other control software is running in background?

On my device the LEDs can be set as expected....

Mayby someone other is continously resetting the LED state ?

Are you shure no NodeRed or other is running?

NSURLSession0 commented 3 years ago

That's strange. I am using a fresh stretch installation that came with the RevPi Core 3. I have not installed any other software apart from mono and the dotnet 3.1 runtime.

Since n14s from issue #1 had the same issue, maybe you have something configured differently on your RevPi?

FrankPfattheicher commented 3 years ago

@Mauricevb did you try the original supplied pitest ? DOes that work ?

FrankPfattheicher commented 3 years ago

@Mauricevb now i flashed my RevPiCore new with 2020-06-25-revpi-stretch.img Done initial startup configuration with PiCtory (RevPiCore device only) Copieed PiTest (netcore31 single file published) using VNC

Setting LEDs works as expected - so how to continue here?

NSURLSession0 commented 3 years ago

@FrankPfattheicher Thank you for trying! Can you share your executable? Maybe it has something to do with the compiling.

FrankPfattheicher commented 3 years ago

@Mauricevb uploaded as a release. See https://github.com/FrankPfattheicher/RevolutionPi/releases/tag/Nov2020

FrankPfattheicher commented 3 years ago

A invalid definition of IOC_VOID in Interop.cs is now fixed. Please retry.

NSURLSession0 commented 3 years ago

My power supply is not working anymore so I have to wait for a new one. I will get back to you asap :)

NSURLSession0 commented 3 years ago

Hi @FrankPfattheicher, I just checked the latest version on my RevPi and it works like a charm now! Thank you very much for all your help and patience :)

FrankPfattheicher commented 3 years ago

Great ! Thanks for feedback.