MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

icon
Avatar
Otacon
Posts: 21
Hey there,

I am new to MobiFlight and I have two hopefully not so dumb questions.

At first: I use X-Plane with XPUIPC.
Everything is connected as it should.
When I use the FSUIPC Offset presets I have no problems to light a LED on the board or to flip a switch in the game.
But when it comes to using other Offsets (I found a list at projectmagenta) it won't work.

I understand the basic philosophy of having a datastream, where you choose a specific position (Offset) where you can, for example, switch a bit from 0 to 1.
What it don't get is the option "mask value with". What is this for?

I also have a question regarding XPUIPC that I hope I can ask here.
I found a config file where the offsets are mapped to datarefs.
Here I found datarefs named uint16 for example. Does the 16 describe the datasize?
[Last edited by Otacon, 2018-07-24 15:24]
Greetings,
Maik
2018-07-24 12:51
Avatar
StephanHo
From: EDDG, Germany
Posts: 1541
Supporter
Hi Maik,

welcome to Mobiflight.

If you sign a message with Gruß, Maik, then you should talk in German. So you left you Message in the German Part of Mobiflight an the german language should be ok.

To your problems:

Mask values - here we need an excursion how to work with bits. You know, these 0 and 1.
If you add in our normal number_system (to the base of 10) 5 + 5 is the result 10. You have now not more 1 digit rather an overflow to the 2nd digit. So you add 5 + 5 is 0 overflow 1, called 10
If you add in the dual (binary) number_system (only 0 and 1) 1 + 1 you won't get 2 because this number is not possible. You have only 0 and 1! So you get 1 + 1 = 0 overflow 1, called, no, not 10 (ten), rather 1-0 (one-zero).
In the computer technology we know bits (the smallest unit), nibbles (4 bit in a row), Bytes (8 bit or 2 Nibbles), Word (16 Bit, 4 Nibbles or 2 Bytes), Double-Word (32 Bit, 8 Nibbles, 4 Bytes). Thera are also a lot of others, but these we don't need today.

If you have for example a value of 01010111 (1 Byte, two nibbles) so you can also write it as 0101 0111 for better readability.
Now you have to know that the left bit of the byte is the MSB (Most Significant Bit) and the rightest Bit is the LSB (Least Significant Bit). This ist important to know, because if you have to convert it into the decimal (our well known) number_system.
Back to our byte. This Byte can now be masked if I want to know the contents of a particular bit. Here we have to go back a little deeper into the matter.

You've probably heard the term truth table before. Masks are normally ANDed with a value.

Truth table for AND
(V1=value1, V2=value2, R=result)
V1 V2 R
0 0 0
0 1 0
1 0 0
1 1 1

As you see, only if V1 AND V2 are equal the result is 1.

This is how a mask works

Mobiflight normaly uses F or FF or FFFF or many of them as mask.
Oops, what is F. Ok, the next number_system, this time the hexadecimal number system. The base is 16. Hexadecimal is also known as sedecimal system but it's the same only another name. The abreviation is HEX

FFHEX or 0xFF or FF16 - all the same
How do you get to the F? The numbers 0,1,2....9 are well known, continues with A, B, C, D, E and F

Comparison of the valences DEC BIN HEX

DEC BIN HEX
00 0000 0
01 0001 1
02 0010 2
03 0011 3
04 0100 4
05 0101 5
06 0110 6
07 0111 7
08 1000 8
09 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F

Back to the mask.
Above we have the Byte 01010111, parted in nibbles 0101 0111 - would be in HEX: 5 7
Back to MF. MF masks this value with FF. But how to mask 0101 0111 with FF?

Exact,we transform FF into binary = 1111 1111
Now we link 0101 0111 with FF

0101 0111
1111 1111

The result if these values are AND-linked is

0101 0111

To check this, use the true table above bitwise.

Another calculation. We want to konow the value of the 2nd bit.
We count from right to left. 0 ist the LSB, 1 the 1st, 2 the 2nd, 3 the 3rd 4 the 4th ... and the MSB (the left one!) ist the 7th! not the 8th.

If we want the value of the 2nd bit (3rd position from right!) we have to know how the mask looks like

0101 0111
0000 0100

0000 0100 is the result because only the 3rd bit interesting and 1
The decimal result is 4 (look table above)

So you can notice: the mask for the LSB is 1, for the 2nd bit is 2, for the 3rd bit is 4, for the 4th bit is 8, for the 5th bit is 16, for the 6th bit is 32, for the 7th bit is 64 and for the 8th bit (MSB ) is 128.

Do you notice something? If you add the values together (1+2+4+8+16+32+64+128) you got 255 or 1111 11112 or 0xFF

So you can compare every value with any mask and get a true result.


uint16:

describes the datalength in BITs - in fact UNSIGNED

I have a small course with dual numbers in preparation, which also deals with this case, but must still be read correction.

So Maik, I hope I could help you a bit ;)
Grüße,
Stephan
2018-07-24 16:03
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3720
Supporter
iconOtacon:



1: But when it comes to using other Offsets (I found a list at projectmagenta) it won't work.
.....
2: I understand the basic philosophy of having a datastream, where you choose a specific position (Offset) where you can, for example, switch a bit from 0 to 1.
What it don't get is the option "mask value with". What is this for?

....
3: I also have a question regarding XPUIPC that I hope I can ask here.
I found a config file where the offsets are mapped to datarefs.
Here I found datarefs named uint16 for example. Does the 16 describe the datasize?



Welcome to Mobiflight.

Stephan already explane the "internal" logics.... For professional cockpitbuilding you should "understand" that stuff.... BUT at beginning i will try to explane it a bit more easy to you.


1: The Presets are just some examples. Your right... You need a List of Offests to work with. BUT. project Magenta List is designed for Project Magenta Software. So lots of Offsets there are not available with other Aircrafts. Also you must note you use XPlane instead of FSX . Only the Offsets that support by XPUIPC ADdOn Programm can be used ( And that are NOT 100% of the exisiting Offsets)
So you shouldm google for a "XPUIPC Offset List"

***
2. You mixed up BIT and BYTE Here.
In Most Offsets we not set a BIT from 0 to 1 ... We simply write the Value of the BYTE to 1 or 0 .
Those Bytes are mostly named "Boolean" in the Lists.... Means it can have TWO Conditions. True or False ...
ZERO is always FALSE and mean OFF all other Value like 1,2,3 or maby 999999999 is TRUE ( But shure.... Most offsets simply use "1" for True. )

Now to the " mask value with" Part.
SOME Offsets like for example Radio Controlls are BIT Based ( Not BYTE )
iconQuote:

3122 1 Radio audio switches. Read/write bit settings as follows:
2^7 COM1 transmit
2^6 COM2 transmit
2^5 COM receive both
2^4 NAV1 sound
2^3 NAV2 sound
2^2 Marker sound
2^1 DME sound
2^0 ADF1 sound



Here you have 1 byte (Including 8 Bits) and Every Bit is controlling ONE Function .
If you like to controll for example the COM1 transmit LED you need to "mask" the Value so only BIT 7 (The left one) is checked and all other are unchecked in that mask.
Then you Read or write ONLY this Bit and not the other 7 bits.

***
3:
About File System Stephan told everything.
For you is inportant.... XPUIPC talk to the Dataref ( the internal Xplane logic) .... But we dont need to think about it.... Cause XPUIPC will support this stuff to a virtual FSUIPC Table that we can read simply with Mobiflight.
You only need to work with this stuff if you like to rework the XPUIPC System youreself to get more things working. ( Need high programming skills)

***


Summary:
Always note that Xplane is not 100% designed for Mobiflight. You can do a lot of things.... and with Programming skills you can do ALL things. But working with P3D is much more comfortable att all if you plan to use Mobiflight in the future.
Good Luck !
2018-07-24 16:20
Avatar
Otacon
Posts: 21
iconQuote:

If you sign a message with Gruß, Maik, then you should talk in German. So you left you Message in the German Part of Mobiflight an the german language should be ok.


Oh dass tut mir leid, ich mehrere Leute mit deutschen Grüßen in der Signatur gesehen, die trotzdem englisch geschrieben haben.

Vielen lieben Dank für die umfangreichen Erklärungen.
Jetzt fühle ich mich erleuchtet. Vor allem die Erklärung zu den Byte- und Bitweisen Offsets.

Jetzt kann ich zumindest den Alternator auch wieder ausschalten :rolleyes:
Den Starter Switch kann ich zwar immernoch nicht bewegen, aber das liegt bestimmt am XPUIPC.

Danke!:)
Greetings,
Maik
2018-07-24 23:07
Avatar
StephanHo
From: EDDG, Germany
Posts: 1541
Supporter
Hi Maik,

nein, es muß dir nicht leid tun. Offiziell gilt hier im Forum sowohl deutsch als auch englisch.

Manchmal breche ich mir zumindest in english einen ab und nutze dann den Google-Übersetzer oder versuche einfache Umschreibungen, wenn mir Google zu strange klingt.

Normalerweise wird in der Sprache geantwortet, die der Ersteller des Topics nutzt (jedenfalls eine der beiden). Aber in deutsch oder eben seiner Muttersprache kann man sich meist besser ausdrücken, als dies in einer Fremdsprache möglich ist.

X-Plane ist für mich ein Buch mit 7 Siegeln und kann da gar nichts zu sagen. Wenn es aber um digitale Abläufe, Umstände oder Umrechnungen geht, so kann man das halt für jeden Flieger benutzen.

Es gibt hier einige die über MF X-Plane nutzen, insofern brauchst du dich nicht mit Fragen zurückhalten. Wie es für jedes Problem eine Lösung gibt, gibt es hier auch immer Leute, die einem weiterhelfen. Insofern gibt es keine dummen Fragen, nur dumme Antworten ;)

Viel Erfolg weiterhin beim Cockpitbau!
Grüße,
Stephan
2018-07-24 23:49
Avatar
Otacon
Posts: 21
Ich Depp habe jetzt auch meinen Fehler mit dem Starter Switch gefunden.
Ich dachte die einzelnen Zustände wären Bit-basiert (2^0 bis 2^4).
Statt dessen sind das absolute Werte. also Maske auf FFFF und Wert auf 0 bis 4.

Ein schönes Wochenende euch allen!
Greetings,
Maik
2018-07-28 15:17
Avatar
StephanHo
From: EDDG, Germany
Posts: 1541
Supporter
Na, geh mal nicht so hart mit dir ins Gericht.

Fehler sind schließlich dafür da, gemacht zu werden, und nur wer arbeitet, kann Fehler machen ;)

Aber: Lerne aus den Fehlern anderer, du lebst nicht lange genug, sie alle selbst zu begehen...
Grüße,
Stephan
2018-07-28 15:48
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3720
Supporter
iconOtacon:

Ich Depp habe jetzt auch meinen Fehler mit dem Starter Switch gefunden.
Ich dachte die einzelnen Zustände wären Bit-basiert (2^0 bis 2^4).
Statt dessen sind das absolute Werte. also Maske auf FFFF und Wert auf 0 bis 4.




Erneut ein wenig was vermischt !

Du hast schon Recht gehabt.... Wenn ein Offset in der Beschreibung 2^0... 2^1.... 2^2 etc stehen hat dann IST er Bit Basiert.
Der Standard Offset für den Starter Switch ist dies allerdings nicht.

iconCode:
0892 2 Engine 1 Starter switch position (Magnetos),
Jet/turbojet: 0=Off, 1=Start, 2=Gen/Alt
Prop: 0=Off, 1=right, 2=Left, 3=Both, 4=Start


Falls du ein AddOn verwendest oder einen anderen Offset solltest du nochmal nachprüfen.!!!

Denn wenn du auf einen Bit Basierten Offset auf den ganzen Byte volle zahlen schreibst änderst du ja auch die Bits !
Schreibst du 1 ist das wie wenn du BIT-0 auf True setzt .... Schreibst du 2 dann setzt du Bit 1 auf True. Schreibst du 3 dann setzt du Bit 0 UND 1 auf True ( Was vermutlich dann einen Fehler verursacht weil deine Funktion dann 2 Inputs gleichzeitig kriegt.

Also Vorsicht !!! den Offset immer so behandeln wie er ist und nicht profisorische Lösungen machen die nur "scheinbar" Funktionieren aber am Ende Probleme machen die kein Schwein finden kann weil die Grundlogik falsch ist.
Good Luck !
2018-07-28 17:04
Avatar
Otacon
Posts: 21
Danke StephanHo für die weißen Worte und danke Pizman82 für den Hinweis!

Aktuell fliege ich nur die Standard-Flugzeuge, aber ich werde mir das im Hinterkopf behalten.
Greetings,
Maik
2018-07-29 15:05
icon