Datenkonvertierung Motorola(Big Endian) zu Intel(Little endian)

More
22 Oct 2018 10:56 - 04 Nov 2018 13:52 #119200 by andrax
Hallo,

ich bekomme Positionsdaten im Motorola Format (Big Endian)
Die sehen in Hex so aus:0x 02 01 04 03
Ich brauch die aber in Linuxcnc im Intelformat (Little Endian), damit sie korrekt angezeigt und verarbeitet werden können.
Also so: 0x 01 02 03 04

Gibt es eine Funktion in der Hal mit der ich die Daten entsprechend konvertieren kann,
bzw. eine Möglichkeit die Bytes aufzudröseln und entsprechend wieder zusammenzusetzen?


Besten Dank in Vorraus

Andre
Last edit: 04 Nov 2018 13:52 by andrax.

Please Log in or Create an account to join the conversation.

More
23 Oct 2018 15:33 #119265 by andypugh
The tidy way way:
linuxcnc.org/docs/2.7/html/hal/comp.html

I thought about doing it with bitslice and weighted-sum but weighted-sum only processes 16 bits of data.

UNTESTED!
component endian "swap endian-ness of a 32 bit integer";
pin in unsigned in;
pin out unsigned out;
license "GPL2+";
author "andypugh";
function _;
;;
FUNCTION(_){
    int temp1, temp2;
    temp1 = in & 0xFFFF0000 >> 16;
    temp2 = in & 0x0000FFFF << 16;
    out = temp1 | temp2;
}
The following user(s) said Thank You: tommylight, andrax

Please Log in or Create an account to join the conversation.

More
24 Oct 2018 12:41 #119330 by andrax
Das ist eine super Idee.
Hätt ich selber drauf kommen können

Vielen Dank

Andre

Please Log in or Create an account to join the conversation.

More
26 Oct 2018 16:08 - 26 Oct 2018 16:09 #119456 by andrax
Hallo,

ich habe mir die Funktion erstellt.
Ich benutze Linuxcnc 2.6.13
Die funktion habe ich "Conv_Intel_Motorola.comp" benannt.

Ich habe sie Compiliert ind installiert.
comp --compile Conv_Intel_Motorola.comp
comp --install Conv_Intel_Motorola.comp

In der .hal habe ich
loadrt Conv_Intel_Motorola --> OK
addf Conv_Intel_Motorola servo-thread

Hier bekomme ich HAL: ERROR: funktion 'Conv_Intel_Motorola' not found

Danach habe ich es mit

addf Conv_Intel_Motorola.0 servo-thread

probiert und bekomme ebenfalls

HAL: ERROR: funktion 'Conv_Intel_Motorola.0' not found

was ist falsch?
Last edit: 26 Oct 2018 16:09 by andrax.

Please Log in or Create an account to join the conversation.

More
26 Oct 2018 16:59 #119465 by andypugh
Welches Version LinuxCNC? Heute ist "comp" "halcompile"

Filename und "component "name";" muss genau übereinstimmen
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
26 Oct 2018 17:24 #119470 by andrax
OK,

bin einen Schritt weiter.
Aus irgend einen Grund läd er mein Modul als Conv-Intel-Motorola.0

Also muss ich die Funktion folgendermaßen aufrufen

addf Conv-Intel-Motorola.0 servo-thread

Aber wie Kann ich die Funktion benutzen?
Conv-Intel-Motorola.0 lcec.0.3.ist_pos_data Istposition >>> funktioniert nicht.
Wie ist die richtige Syntax ?

Gruß

Andre

Please Log in or Create an account to join the conversation.

More
26 Oct 2018 17:44 - 26 Oct 2018 17:44 #119472 by andypugh
net a-signal-name-of-your-choice  lcec.0.3.ist_pos_data => Conv-Intel-Motorola.0.in
net another-signal-name Conv-Intel-Motorola.0.out => destination pin
Last edit: 26 Oct 2018 17:44 by andypugh.
The following user(s) said Thank You: tommylight, andrax

Please Log in or Create an account to join the conversation.

More
26 Oct 2018 18:31 - 29 Oct 2018 05:23 #119475 by andrax
Last edit: 29 Oct 2018 05:23 by andrax.

Please Log in or Create an account to join the conversation.

More
29 Oct 2018 09:04 #119584 by andrax
Hallo,

jetzt stellt sich mir doch noch eine Frage.
Kann ich meine Funktion instanzieren?
Das ist jetzt so gemeint, ob ich die selbe Funktion für unterschiedliche Aufgaben (Pins und Achsen) benutzen kann.
Oder muss ich für jeden Pin/Achse eine eigene Funktion erstellen, bzw. meine Funktion um entsprechende in/out erweitern.

Vielen Dank im Voraus

Gruß

Andre

Please Log in or Create an account to join the conversation.

More
30 Oct 2018 10:59 #119640 by andypugh
loadrt Conv-Intel-Motorola count=6

oder
loadrt Conv-Intel-Motorola names=conv-x,conv-y,conv-z
(keine Leerzeichen)
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

Time to create page: 0.194 seconds
Powered by Kunena Forum