(ComputerCraft) (minecraft version 1.7.10) (question) Make a language file reader - lua

I'd like to make a language reader for my operating system, but I cant find anything that helps me.
I want to put the list into my other script.
Heres the de-de language file (location: /os/bin/):
de = {
Menu = "Menü",
Shutdown = "Ausschalten",
MenuLength = 4,
ShutdownLength = 11
}
Can anyone help me please?

The gsub() string function/method can do that with your translation table.
You only have to use your language table for that.
Example...
# /usr/bin/lua
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
> de = {
>> Menu = "Menü",
>> Shutdown = "Ausschalten",
>> MenuLength = 4,
>> ShutdownLength = 11
>> }
> language = de
> print(('Menu Shutdown'):gsub('(%g+)', language))
Menü Ausschalten 2
If you have to use Lua 5.1 then use %w...
# /bin/lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> de = {
>> Menu = "Menü",
>> Shutdown = "Ausschalten",
>> MenuLength = 4,
>> ShutdownLength = 11
>> }
> language = de
> print(('Menu Shutdown'):gsub('(%w+)', language))
Menü Ausschalten 2
The length can be measured with the len() function/method...
> print(('Shutdown'):gsub('(%w+)', language):len())
11
> print(('Menu'):gsub('(%w+)', language):len())
5
As you can see in Lua the Umlaut ü is measured different.
To include your de-de.lua i suggest dofile() that loads it with your specific path...
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> dofile('/os/bin/de-de.lua') -- But read comment about security
> print(de['Menu'])
Menü
Try to convert the special words with german Umlaut into its byte representation.
And put the bytes into your translation table...
$ lua
Lua 5.4.3 Copyright (C) 1994-2021 Lua.org, PUC-Rio
> print(('Menü'):byte(1,-1))
77 101 110 195 188
> print('\77\101\110\195\188')
Menü
> de = {Menu = '\77\101\110\195\188'}
> print(('Menu'):gsub('%g+', de))
Menü 1
...or for Lua 5.1...
$ /bin/lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> print(('Menü'):byte(1, -1))
77 101 110 195 188
> print('\77\101\110\195\188')
Menü
> de = {Menu = '\77\101\110\195\188'}
> print(('Menu'):gsub('%w+', de))
Menü 1
You also can mix it.
And here are the bytes for: üäößÜÄÖ
> print(('üäößÜÄÖ'):byte(1, -1))
195 188 195 164 195 182 195 159 195 156 195 132 195 150
> de = {Menu = 'Men\195\188', Umlaute = '\195\188\195\164\195\182\195\159\195\156\195\132\195\150'}
> print(('Menu Umlaute'):gsub('%w+', de))
Menü üäößÜÄÖ 2

Related

How to fix leaks memory valgrind using linekd list?

I built a set linked list known that I can not add the same item two times to my set so I have implemented this procedure, but when i run program.adb below i still having a leaks memory especially with Nouvelle_Cellule := New T_Cellule'(Element, Null); then i don't understand this leak memory.
linked_set.adb
56 procedure Ajouter (Ensemble : in out T_Ensemble; Element : in T_Element) is
57 Nouvelle_Cellule, Temp : T_Ensemble;
58 begin
59 Nouvelle_Cellule := New T_Cellule'(Element, Null);
60 if ( Ensemble = Null) then -- Si l'ensemble est vide.
61 Ensemble := Nouvelle_Cellule; --Créer une nouvelle cellule.
62 else -- Sinon, on ajoute à la fin de l'ensemble.
63 Temp := Ensemble;
64
65 while (Temp.all.Suivant /= Null) loop
66
67 Temp := Temp.all.Suivant;
68 end loop;
69 Temp.all.Suivant := Nouvelle_Cellule; --Créer une nouvelle cellule.;
70 end if;
71 end Ajouter;
And I have a simple program using ajouter method :
nombre_moyen_tirages_chainage.adb
1 with Ensembles_Chainage;
2 with Alea;
3 with Ada.Text_IO; use Ada.Text_IO;
4
5 -- Cette procédure calculera le nombre moyen de tirages qu’il faut
6 -- faire pour obtenir tous les nombres d’un intervalle entier Min..Max en
7 -- utilisant le générateur de nombre aléatoire.
8 procedure Nombre_Moyen_Tirages_Chainage is
9 Min : Constant integer := 10; -- La borne inférieure.
10 Max : Constant integer := 20; -- La borne supérieure.
11 Essais : Constant integer := 100; -- Le nombre d'essais.
12
13 package Mon_Alea is
14 new Alea (Min, Max); -- Générateur de nombre dans l'intervalle [1, 10].
15 use Mon_Alea;
16
17 package Ensembles_Entiers is -- Instantiation du package Ensembles_Chainage.
18 new Ensembles_Chainage (T_Element => Integer);
19 use Ensembles_Entiers;
20
21 Ensemble : T_Ensemble; -- Déclarer une variable ensemble.
22 Moyenne : Integer; -- La variable moyenne qui stockera le nombre moyen de tirages.
23 n_alea: Integer; -- Le nombre aléatoire généré.
24 begin
25 New_Line;
26 Put_Line("*************************** Début ****************************");
27 New_Line;
28 Moyenne := 0; -- Initialiser Moyenne à 0.
29
30 for i in 1..Essais loop
31 Initialiser (Ensemble); -- Initialiser un ensemble vide.
32
33 loop
34 Get_Random_Number(n_alea); -- Obtenir un nombre aléatoire.
35 Moyenne := Moyenne + 1; -- Incrementer Moyenne.
36
37 if not(Est_Present (Ensemble, n_alea)) then
38 ajouter (Ensemble, n_alea); -- Ajouter n_alea à l'ensemble.
39 end if;
40 exit when Taille (Ensemble) = Max - Min + 1;
41 end loop;
42 end loop;
43
44 Moyenne := Moyenne / Essais; -- Calculer la Moyenne.
45 Put_Line("le nombre moyen de tirages qu’il faut faire pour obtenir tous");
46 Put_Line("les nombres entre" & Integer'Image(Min) & " et" & Integer'Image(Max) & " est : " & Inte ger'Image(Moyenne));
47
48 New_Line;
49 Put_Line("***************************** Fin ****************************");
50 New_Line;
51
52 end Nombre_Moyen_Tirages_Chainage;
Then when I compile and execute with valgrind this program it displays a leak memory related to ajouter function in linked_set.adb:
==19122== Memcheck, a memory error detector
==19122== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19122== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==19122== Command: ./nombre_moyen_tirages_chainage
==19122==
*************************** Début ****************************
le nombre moyen de tirages qu’il faut faire pour obtenir tous
les nombres entre 10 et 20 est : 34
***************************** Fin ****************************
==19122==
==19122== HEAP SUMMARY:
==19122== in use at exit: 17,600 bytes in 1,100 blocks
==19122== total heap usage: 1,111 allocs, 11 frees, 24,160 bytes allocated
==19122==
==19122== 17,600 (1,600 direct, 16,000 indirect) bytes in 100 blocks are definitely lost in loss record 2 of 2
==19122== at 0x483A7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==19122== by 0x4AA78CF: __gnat_malloc (in /usr/lib/x86_64-linux-gnu/libgnat-8.so.1)
==19122== by 0x10C3AB: nombre_moyen_tirages_chainage__ensembles_entiers__ajouter.4561 (ensembles_chainage.adb:59)
==19122== by 0x10BABD: _ada_nombre_moyen_tirages_chainage (nombre_moyen_tirages_chainage.adb:38)
==19122== by 0x10B924: main (b~nombre_moyen_tirages_chainage.adb:247)
==19122==
==19122== LEAK SUMMARY:
==19122== definitely lost: 1,600 bytes in 100 blocks
==19122== indirectly lost: 16,000 bytes in 1,000 blocks
==19122== possibly lost: 0 bytes in 0 blocks
==19122== still reachable: 0 bytes in 0 blocks
==19122== suppressed: 0 bytes in 0 blocks
==19122==
==19122== For lists of detected and suppressed errors, rerun with: -s
==19122== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
How can I fix this problem please.
You will find the entire code in my github page : https://github.com/MOUDDENEHamza/pim/tree/master/tp/pr2
Perhaps you leak on deleting, not adding ?
You add entries to your linked list, but you don’t delete them, so when your program exits the entries are still there in the list, and valgrind sees this as a leak. It isn’t really: the operating system will clean up automatically.
You could just live with this (I would), but if you want to clean up you could do so explicitly as #DeeDee suggests, or you could explore making your linked list (limited) controlled.
I think you need to initialize the list before the inner loop and call Detruire (English: Destroy) afterwards. The Detruire subprogram uses Ada.Unchecked_Deallocation to deallocate the list's elements (see here) which were previously allocated with (in this case):
Nouvelle_Cellule := New T_Cellule'(Element, Null);
Here's the adaptation:
program.adb (partial)
for i in 1..Essais loop
Initialiser (Ensemble); -- Initialize
loop
Get_Random_Number(n_alea); -- Obtenir un nombre aléatoire.
Moyenne := Moyenne + 1; -- Incrementer Moyenne.
if not(Est_Present (Ensemble, n_alea)) then
Ajouter (Ensemble, n_alea); -- Ajouter n_alea à l'ensemble.
end if;
exit when Taille (Ensemble) = Max - Min + 1;
end loop;
Detruire (Ensemble); -- Destroy
end loop;
output (valgrind)
$ valgrind ./nombre_moyen_tirages_chainage
==1353== Memcheck, a memory error detector
==1353== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1353== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==1353== Command: ./nombre_moyen_tirages_chainage
==1353==
*************************** Début ****************************
le nombre moyen de tirages qu’il faut faire pour obtenir tous
les nombres entre 10 et 20 est : 34
***************************** Fin ****************************
==1353==
==1353== HEAP SUMMARY:
==1353== in use at exit: 0 bytes in 0 blocks
==1353== total heap usage: 1,111 allocs, 1,111 frees, 24,339 bytes allocated
==1353==
==1353== All heap blocks were freed -- no leaks are possible
==1353==
==1353== For counts of detected and suppressed errors, rerun with: -v
==1353== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
There's also a missing deallocation in the Supprimer (English: remove) subprogram:
ensembles_chainage.adb (partial)
procedure Supprimer (Ensemble : in out T_Ensemble; Element : in T_Element) is
begin
if (Ensemble.all.Element = Element) then
declare
Temp : T_Ensemble := Ensemble;
begin
Ensemble := Ensemble.all.Suivant;
Free (Temp);
end;
else
Supprimer (Ensemble.all.Suivant, Element);
end if;
end Supprimer;

Parse input text that is located using left padding spaces

I have the following text structure. The values below JTT JNX JNA JNO belong to previous line.
9 8 11 56507785 93
JTT JNX JNA JNO
76 98
9 8 60 3269557 58
9 8 53 7269558 150
JTT JNX JNA JNO
132 71 45-7705678
9 8 62 439559 82
I'd like to parse it in order to print the corresponding values in a single line like below:
H1 H2 H3 H4 H5 JTT JNX JNA JNO
9 8 11 56507785 93 76 98
9 8 60 3269557 58
9 8 53 7269558 150 132 71 45-7705678
9 8 62 439559 82
My issue is when I use awk with FS = space (default FS) then it takes JTT as first field and JTT has 9 spaces before, so I think should be use some technique that counts how may spaces are from left until JTT JNX JNA JNO and count number of spaces from beginning until the values below JTT JNX JNA JNO in order to positionate correctly each value. I mean, 76 and 132 below JTT header, 971 below JNX, 98 below JNA and 45-7705678 below JNO.
How can this be done in awk?
$ awk --version
GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2019 Free Software Foundation.
$ uname -srv
CYGWIN_NT-6.1 3.0.7(0.338/5/3) 2019-04-30 18:08
Thanks in advance.
With GNU awk (which you have) for FIELDWIDTHS:
$ cat tst.awk
BEGIN {
OFS = ","
print "H1", "H2", "H3", "H4", "H5", "JTT", "JNX", "JNA", "JNO"
}
!NF || ($1 == "JTT") { next }
!/^ / {
if (NR>1) {
print rec
}
FS = " "
$0 = $0
$1 = $1
rec = $0
}
/^ / {
FIELDWIDTHS = "12 5 5 *"
$0 = $0
$1 = $1
for (i=1; i<=NF; i++) {
gsub(/^\s+|\s+$/,"",$i)
}
rec = rec OFS $0
}
END {
print rec
}
.
$ awk -f tst.awk file
H1,H2,H3,H4,H5,JTT,JNX,JNA,JNO
9,8,11,56507785,93,76,,98
9,8,60,3269557,58
9,8,53,7269558,150,132,71,,45-7705678
9,8,62,439559,82
$ awk -f tst.awk file | column -s, -t
H1 H2 H3 H4 H5 JTT JNX JNA JNO
9 8 11 56507785 93 76 98
9 8 60 3269557 58
9 8 53 7269558 150 132 71 45-7705678
9 8 62 439559 82
Replace OFS="," with OFS="\t" or otherwise massage to suit...

Decode UDP message with LUA

I'm relatively new to lua and programming in general (self taught), so please be gentle!
Anyway, I wrote a lua script to read a UDP message from a game. The structure of the message is:
DATAxXXXXaaaaBBBBccccDDDDeeeeFFFFggggHHHH
DATAx = 4 letter ID and x = control character
XXXX = integer shows the group of the data (groups are known)
aaaa...HHHHH = 8 single-precision floating point numbers
The last ones is those numbers I need to decode.
If I print the message as received, it's something like:
DATA*{V???A?A?...etc.
Using string.byte(), I'm getting a stream of bytes like this (I have "formatted" the bytes to reflect the structure above.
68 65 84 65/42/20 0 0 0/237 222 28 66/189 59 182 65/107 42 41 65/33 173 79 63/0 0 128 63/146 41 41 65/0 0 30 66/0 0 184 65
The first 5 bytes are of course the DATA*. The next 4 are the 20th group of data. The next bytes, the ones I need to decode, and are equal to those values:
237 222 28 66 = 39.218
189 59 182 65 = 22.779
107 42 41 65 = 10.573
33 173 79 63 = 0.8114
0 0 128 63 = 1.0000
146 41 41 65 = 10.573
0 0 30 66 = 39.500
0 0 184 65 = 23.000
I've found C# code that does the decode with BitConverter.ToSingle(), but I haven't found any like this for Lua.
Any idea?
What Lua version do you have?
This code works in Lua 5.3
local str = "DATA*\20\0\0\0\237\222\28\66\189\59\182\65..."
-- Read two float values starting from position 10 in the string
print(string.unpack("<ff", str, 10)) --> 39.217700958252 22.779169082642 18
-- 18 (third returned value) is the next position in the string
For Lua 5.1 you have to write special function (or steal it from François Perrad's git repo )
local function binary_to_float(str, pos)
local b1, b2, b3, b4 = str:byte(pos, pos+3)
local sign = b4 > 0x7F and -1 or 1
local expo = (b4 % 0x80) * 2 + math.floor(b3 / 0x80)
local mant = ((b3 % 0x80) * 0x100 + b2) * 0x100 + b1
local n
if mant + expo == 0 then
n = sign * 0.0
elseif expo == 0xFF then
n = (mant == 0 and sign or 0) / 0
else
n = sign * (1 + mant / 0x800000) * 2.0^(expo - 0x7F)
end
return n
end
local str = "DATA*\20\0\0\0\237\222\28\66\189\59\182\65..."
print(binary_to_float(str, 10)) --> 39.217700958252
print(binary_to_float(str, 14)) --> 22.779169082642
It’s little-endian byte-order of IEEE-754 single-precision binary:
E.g., 0 0 128 63 is:
00111111 10000000 00000000 00000000
(63) (128) (0) (0)
Why that equals 1 requires that you understand the very basics of IEEE-754 representation, namely its use of an exponent and mantissa. See here to start.
See #Egor‘s answer above for how to use string.unpack() in Lua 5.3 and one possible implementation you could use in earlier versions.

ctags: To get C function end line number

is it possible via ctags to get the function end line number as well
"ctags -x --c-kinds=f filename.c"
Above command lists the function definition start line-numbers. Wanted a way to get the function end line numbers.
Other Approaches:
awk 'NR > first && /^}$/ { print NR; exit }' first=$FIRST_LINE filename.c
This needs the code to be properly formatted
Example:
filename.c
1 #include<stdio.h>
2 #include<stdlib.h>
3 int main()
4 {
5 const char *name;
6
7 int a=0
8 printf("name");
9 printf("sssss: %s",name);
10
11 return 0;
12 }
13
14 void code()
15 {
16 printf("Code \n");
17 }
18
19 int code2()
20 {
21 printf("code2 \n");
22 return 1
23 }
24
Input: filename and the function start line no.
Example:
Input: filename.c 3
Output: 12
Input : filename.c 19
Output : 23
Is there any better/simple way of doing this ?
C/C++ parser of Universal-ctags(https://ctags.io) has end: field.
jet#localhost tmp]$ cat -n foo.c
1 int
2 main( void )
3 {
4
5 }
6
7 int
8 bar (void)
9 {
10
11 }
12
13 struct x {
14 int y;
15 };
16
[jet#localhost tmp]$ ~/var/ctags/ctags --fields=+ne -o - --sort=no foo.c
main foo.c /^main( void )$/;" f line:2 typeref:typename:int end:5
bar foo.c /^bar (void)$/;" f line:8 typeref:typename:int end:11
x foo.c /^struct x {$/;" s line:13 file: end:15
y foo.c /^ int y;$/;" m line:14 struct:x typeref:typename:int file:
awk to the rescue!
doesn't handle curly braces within comments but should handle blocks within functions, please give it a try...
$ awk -v s=3 'NR>=s && /{/ {c++}
NR>=s && /}/ && c && !--c {print NR; exit}' file
finds the matching brace for the first one after the specified start line number s.

Beaglebone black (BBB) rev C 3.8.13-38-ARCH SPI doesn't work, Inappropriate ioctl for device

I have troubles with enabling SPI on BBB, ofc followed tutorial from the hipstercircuits.com.
I even installed a fresh arch linux to the uSD in case I really messed up system on eMMC.
My settings are:
Since SPI1 has issues with HDMI I disabled anything HDMI related I found.
Not sure about fdfile entry though, found it somewhere on the web. (I also tried without it)
Currently I'm working on the SD card if that matters.
uEnv.txt
optargs=quiet coherent_pool=1M fdtfile=am335x-boneblack.dtb capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
I took dts file straight from the hipstercircuits.com and compiled it with alarm/dtc-overlay 1.4.1-1 installed via pacman.
After disabling HDMI in uEnv.txt
[root#alarm ~]# echo BB-SPI1-01 > /sys/devices/bone_capemgr.*/slots
went ok and I saw:
[root#alarm ~]# cat /sys/devices/bone_capemgr.9/slots
0: 54:PF---
1: 55:PF---
2: 56:PF---
3: 57:PF---
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI1-01
I also tried echoing BB-SPIDEV0, BB-SPIDEV1 and BB-SPIDEV1A1 found here:
[root#alarm spi_a]# ls -l /lib/firmware | grep SPI
-rw-r--r-- 1 root root 1351 Jan 29 17:04 BB-SPI1-01-00A0.dtbo
-rw-r--r-- 1 root root 1185 Jan 25 01:06 BB-SPIDEV0-00A0.dtbo
-rw-r--r-- 1 root root 1185 Jan 25 01:06 BB-SPIDEV1-00A0.dtbo
-rw-r--r-- 1 root root 1185 Jan 25 01:06 BB-SPIDEV1A1-00A0.dtbo
Result of the spidev_test is always the same.
What is more interesting I didn't see anything about P9_29, P9_31 etc, which are part of SPI1, in pingroups:
[root#alarm ~]# cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups
registered pin groups:
group: pinmux_userled_pins
pin 21 (44e10854)
pin 22 (44e10858)
pin 23 (44e1085c)
pin 24 (44e10860)
group: pinmux_rstctl_pins
pin 20 (44e10850)
group: pinmux_i2c0_pins
pin 98 (44e10988)
pin 99 (44e1098c)
group: pinmux_i2c2_pins
pin 94 (44e10978)
pin 95 (44e1097c)
group: pinmux_mmc1_pins
pin 88 (44e10960)
group: pinmux_emmc2_pins
pin 32 (44e10880)
pin 33 (44e10884)
pin 0 (44e10800)
pin 1 (44e10804)
pin 2 (44e10808)
pin 3 (44e1080c)
pin 4 (44e10810)
pin 5 (44e10814)
pin 6 (44e10818)
pin 7 (44e1081c)
group: pinmux_userled_pins
pin 21 (44e10854)
pin 22 (44e10858)
pin 23 (44e1085c)
pin 24 (44e10860)
The spidevs are present in /dev
[root#alarm ~]# ls -l /dev | grep spi
crw------- 1 root root 153, 1 Jan 29 17:13 spidev1.0
crw------- 1 root root 153, 0 Jan 29 17:13 spidev1.1
To test the interface both python method mentioned in the tutorial and spidev_test.c (spidev_test.c) compiled on the BBB were used.
[root#alarm ~]# gcc spidev_test.c -o spidev_test
In case of python library there is no error but also nothing at the output - not even a clock signal on the SCL line.
spidev_test returns:
[root#alarm spi_a]# ./spidev_test
can't set spi mode: Inappropriate ioctl for device
Aborted (core dumped)
[root#alarm spi_a]# ./spidev_test -D /dev/spidev1.0
can't set spi mode: Inappropriate ioctl for device
Aborted (core dumped)
[root#alarm spi_a]# ./spidev_test -D /dev/spidev1.1
can't set spi mode: Inappropriate ioctl for device
Aborted (core dumped)
Do I have to make use of *.dts and *.dtb files provided at the beginning of the hipstercircuit's tutorial?
I probably screwed up sth easy. Any ideas what was it?
Did you get it working just like that?
All advices are welcome and will be very appreciated! ;)
I used this .dts and worked fine (both spidev1.0 and spidev1.1 on the spidev_test.c). There are some more lines than in the linux documentation which allow to enable second chip select for being used by SPI1 and properly configure the GPIO on the pin 42.
You should see now the spi pin muxing correctly.
/*
* Copyright (C) 2013 CircuitCo
*
* Virtual cape for SPI1 on connector pins P9.29 P9.31 P9.30 P9.28
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";
/* identification */
part-number = "BB-SPI1-01";
version = "00A0";
/* state the resources this cape uses */
exclusive-use =
/* the pin header uses */
"P9.31", /* spi1_sclk */
"P9.29", /* spi1_d0 */
"P9.30", /* spi1_d1 */
"P9.28", /* spi1_cs0 */
"P9.42", /* spi1_cs1 */
/* the hardware ip uses */
"spi1";
fragment#0 {
target = <&am33xx_pinmux>;
__overlay__ {
/* default state has all gpios released and mode set to uart1 */
bb_spi1_pins: pinmux_bb_spi1_pins {
pinctrl-single,pins = <
0x190 0x33 /* mcasp0_aclkx.spi1_sclk, INPUT_PULLUP | MODE3 */
0x194 0x33 /* mcasp0_fsx.spi1_d0, INPUT_PULLUP | MODE3 */
0x198 0x13 /* mcasp0_axr0.spi1_d1, OUTPUT_PULLUP | MODE3 */
0x19c 0x13 /* mcasp0_ahclkr.spi1_cs0, OUTPUT_PULLUP | MODE3 */
0x164 0x12 /* eCAP0_in_PWM0_out.spi1_cs1 OUTPUT_PULLUP | MODE2 */
0x1A0 0x32 /* Other P42 pin, INPUT_PULLUP */
>;
};
};
};
fragment#1 {
target = <&spi1>; /* spi1 is numbered correctly */
__overlay__ {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&bb_spi1_pins>;
#address-cells = <1>;
#size-cells = <0>;
spi1_0{
#address-cells = <1>;
#size-cells = <0>;
compatible = "spidev";
reg = <0>;
spi-max-frequency = <16000000>;
};
spi1_1{
#address-cells = <1>;
#size-cells = <0>;
compatible = "spidev";
reg = <1>;
spi-max-frequency = <16000000>;
};
};
};};
I think the problem is the ioctl.h.
When I search for 'iotl.h', the result is as follows,
/usr/include/arm-linux-gnueabihf/sys/ioctl.h
/usr/include/arm-linux-gnueabihf/asm/ioctl.h
/usr/include/linux/ioctl.h
/usr/include/linux/hdlc/ioctl.h
/usr/include/linux/mmc/ioctl.h
/usr/include/asm-generic/ioctl.h
So there is no corresponding sys/ioctl.h
I am trying to find the correct ioctl.h

Resources