Spanish Abertis DTT Sat @ Hispasat 30W - Chat & How to guides

mouadhada

Senior Member
Messages
190
 

granavi

Registered
Messages
9
Hi @Adam792

Can you check if my abertis.py is correct?

import sys

pid = int(sys.argv[1])

packet = sys.stdin.buffer.read(188)

while packet !="":
tspid = ((packet[1] & 0x1f) << 8) | packet[2]
if tspid == pid :
afc = packet[3] & 0x30

if afc == 0x10 :
sys.stdout.flush()
sys.stdout.buffer.write(packet[4:])
elif afc == 0x30 :
sys.stdout.flush()
sys.stdout.buffer.write(packet[packet[4]+5:])

packet = sys.stdin.buffer.read(188)

i get this error

mpegts: Abertis PID 702 in Abertis - tuning on IPTV #1
2022-11-28 15:16:36.096 subscription: 0008: "scan" subscribing to mux "Abertis PID 702", weight: 6, adapter: "IPTV #1", network: "Abertis", service: "Raw PID Subscription"
2022-11-28 15:16:36.096 spawn: Executing "/home/hts/Abertis/tdt.sh"
2022-11-28 15:16:37.259 spawn: Traceback (most recent call last):
2022-11-28 15:16:37.259 spawn: File "/home/hts/Abertis/abertis.py", line 9, in
2022-11-28 15:16:37.259 spawn: tspid = ((packet[1] & 0x1f) << 8) | packet[2]
2022-11-28 15:16:37.259 spawn: IndexError: index out of range
2022-11-28 15:16:37.301 iptv: stdin pipe 40 unexpectedly closed: No data
2022-11-28 15:16:51.093 mpegts: Abertis PID 702 in Abertis - scan no data, failed
2022-11-28 15:16:51.093 subscription: 0008: "scan" unsubscribing


Mux 12548 V
{
"sid": 702,
"lcn": 0,
"lcn_minor": 0,
"lcn2": 0,
"srcid": 0,
"dvb_servicetype": 0,
"dvb_ignore_eit": false,
"prefcapid": 0,
"prefcapid_lock": 0,
"force_caid": 0,
"pts_shift": 0,
"created": 1669632706,
"last_seen": 1669632706,
"enabled": true,
"auto": 0,
"priority": 0,
"s_type_user": -1,
"svcname": "Abertis PID 702",
"verified": 1,
"pcr": 702,
"pmt": 8000,
"stream": [
{
"type": "H264",
"pid": 702,
"position": 0
},
{
"pid": 8191,
"type": "CA",
"position": 262144,
"caidlist": [
{
"caid": 9728
}
]
}
],
"uuid": "1a07a33b4b16c59ad969dfe24a463fcf"
}

Ubuntu 20

Tvheadend 4.3.0~pre+202211211947

Oscam-emu (biss verified with tvi Portugal )

Thank and sorry for asking too much
 

Adam792

Senior Member
Messages
102
Hi @Adam792

Can you check if my abertis.py is correct?



i get this error




Mux 12548 V


Ubuntu 20

Tvheadend 4.3.0~pre+202211211947

Oscam-emu (biss verified with tvi Portugal )

Thank and sorry for asking too much

Looks correct, I guess the paste of the code here has just removed the indenting/tabs? (they are important!)

The 12548V mux looks correct too, is the URL for your "Abertis PID 702" IPTV mux set to :

Code:
pipe:///home/hts/Abertis/tdt.sh 1a07a33b4b16c59ad969dfe24a463fcf 702

?

It looks like the Python script is failing because it's getting no data coming into it. You may have to install curl if it isn't already -

Code:
sudo apt install curl
 
Last edited:

EnoSat

Well Known Member
Messages
2,227
i' Want to build for AArch64 in enigma
but astra-sm support only ARM & MIPS
~# opkg install astra-sm
Installing libaio1 (0.3.110) on root.
Downloading http://188.165.252.42/feeds/satdreamgr-6/aarch64/libaio1_0.3.110-r0_aarch64.ipk.
Installing astra-sm (0.2) on root.
Downloading http://188.165.252.42/feeds/satdreamgr-6/aarch64/astra-sm_0.2-r0_aarch64.ipk.
Removing any system startup links for astra-sm ...
Configuring libaio1.
Configuring astra-sm.
Adding system startup for /etc/init.d/astra-sm.

~# opkg install dvbapp-tests
Installing dvbapp-tests (1.1.1) on root.
Downloading http://188.165.252.42/feeds/satdreamgr-6/aarch64/dvbapp-tests_1.1.1-r0_aarch64.ipk.
Configuring dvbapp-tests.
 
Last edited:

locoxloco

Registered
Messages
6
C:
// File: abertis.c
// Compilation: gcc abertis.c -O3 -Wall -o abertis
// Installation: install -m 755 -D abertis /usr/local/bin/abertis

#include <stdbool.h> // bool
#include <stdint.h> // uint8_t, uint16_t
#include <stdio.h> // fprintf, stdout, stderr
#include <stdlib.h> // atoi

#define TS_PACKET_SIZE 188
#define TS_MAGIC_HEADER 0x47
#define AFC_PAYLOAD_ONLY 0b01
#define AFC_ADAPTATION_FIELD_WITH_PAYLOAD 0b11

static inline uint8_t payload_starts_at(uint8_t buffer[TS_PACKET_SIZE]) {
  uint8_t adaptation_field_control = (buffer[3] & 0b00110000) >> 4;
  switch (adaptation_field_control) {
    case AFC_PAYLOAD_ONLY:
      return 4;
    case AFC_ADAPTATION_FIELD_WITH_PAYLOAD:
      return 5 + buffer[4];
    default:
      return TS_PACKET_SIZE;
  }
}

static inline bool is_packet_matched(uint8_t buffer[TS_PACKET_SIZE], uint16_t stream_pid) {
  uint8_t magic_header = buffer[0];
  uint8_t transport_error_indicator = (buffer[1] & 0b10000000) >> 7;
  uint16_t packet_identifier = ((buffer[1] & 0b0000000000011111) << 8) | buffer[2];
  // uint8_t continuity_counter = buffer[3] & 0b00001111;
  bool is_magic_header = magic_header == TS_MAGIC_HEADER;
  bool is_tei_ok = transport_error_indicator == 0;
  bool is_stream_pid = packet_identifier == stream_pid;
  if (!is_tei_ok) {
    fprintf(stderr, "transport error indicator flagged!\n");
  }
  return is_magic_header && is_stream_pid;
}

int main(int argc, char** argv) {
  if (argc != 2) {
    fprintf(stderr, "abertis de-encapsulator\n"
                    "usage: %s <pid>\n", argv[0]);
    return -1;
  }
  uint8_t buffer[TS_PACKET_SIZE];
  uint16_t stream_pid = atoi(argv[1]);
  while (fread(buffer, TS_PACKET_SIZE, 1, stdin)) {
    if (is_packet_matched(buffer, stream_pid)) {
      uint8_t starts_at = payload_starts_at(buffer);
      uint8_t payload_size = TS_PACKET_SIZE - starts_at;
      fwrite(buffer + starts_at, payload_size, 1, stdout);
    }
  }
  fprintf(stderr, "end of file reached!\n");

  return 0;
}
 

Adam792

Senior Member
Messages
102
C:
// File: abertis.c
// Compilation: gcc abertis.c -O3 -Wall -o abertis
// Installation: install -m 755 -D abertis /usr/local/bin/abertis

#include <stdbool.h> // bool
#include <stdint.h> // uint8_t, uint16_t
#include <stdio.h> // fprintf, stdout, stderr
#include <stdlib.h> // atoi

#define TS_PACKET_SIZE 188
#define TS_MAGIC_HEADER 0x47
#define AFC_PAYLOAD_ONLY 0b01
#define AFC_ADAPTATION_FIELD_WITH_PAYLOAD 0b11

static inline uint8_t payload_starts_at(uint8_t buffer[TS_PACKET_SIZE]) {
  uint8_t adaptation_field_control = (buffer[3] & 0b00110000) >> 4;
  switch (adaptation_field_control) {
    case AFC_PAYLOAD_ONLY:
      return 4;
    case AFC_ADAPTATION_FIELD_WITH_PAYLOAD:
      return 5 + buffer[4];
    default:
      return TS_PACKET_SIZE;
  }
}

static inline bool is_packet_matched(uint8_t buffer[TS_PACKET_SIZE], uint16_t stream_pid) {
  uint8_t magic_header = buffer[0];
  uint8_t transport_error_indicator = (buffer[1] & 0b10000000) >> 7;
  uint16_t packet_identifier = ((buffer[1] & 0b0000000000011111) << 8) | buffer[2];
  // uint8_t continuity_counter = buffer[3] & 0b00001111;
  bool is_magic_header = magic_header == TS_MAGIC_HEADER;
  bool is_tei_ok = transport_error_indicator == 0;
  bool is_stream_pid = packet_identifier == stream_pid;
  if (!is_tei_ok) {
    fprintf(stderr, "transport error indicator flagged!\n");
  }
  return is_magic_header && is_stream_pid;
}

int main(int argc, char** argv) {
  if (argc != 2) {
    fprintf(stderr, "abertis de-encapsulator\n"
                    "usage: %s <pid>\n", argv[0]);
    return -1;
  }
  uint8_t buffer[TS_PACKET_SIZE];
  uint16_t stream_pid = atoi(argv[1]);
  while (fread(buffer, TS_PACKET_SIZE, 1, stdin)) {
    if (is_packet_matched(buffer, stream_pid)) {
      uint8_t starts_at = payload_starts_at(buffer);
      uint8_t payload_size = TS_PACKET_SIZE - starts_at;
      fwrite(buffer + starts_at, payload_size, 1, stdout);
    }
  }
  fprintf(stderr, "end of file reached!\n");

  return 0;
}

This is great! Thank you :)

I'm using a C version myself, but just that I made quickly from code used in another tool (the sat DAB ETI-tools). This here looks much nicer, dedicated for the purpose!

Edit: Replaced mine with yours from here, working perfectly. Thanks again
 
Last edited:

EnoSat

Well Known Member
Messages
2,227
try this
1. in Menu - Setup Network WebInterface
"disable anti-hijacking and token-based security in web interface settings" (big thank you again @matt33 and @Rickk)
2. (all files with permission 755) create the abertis.service file in /etc/systemd/system and insert that
Code:
[Unit]
Description = ABERTIS service

[Service]
ExecStart = /ect/init.d/astra-sm &

[Install]
WantedBy = multi-user.target
3. install astra-sm and libaio from ipk
4. with command activate service with:
Code:
systemctl enable abertis.service
5. with command init 4 stop Enigma, replace with lamedb, init 3 and reboot
 

EnoSat

Well Known Member
Messages
2,227
for OE2.5 need next libraries
root@dm900:/tmp# ./t2mi_decap -v
./t2mi_decap: error while loading shared libraries: libcheck.so.0: cannot open shared object file: No such file or directory
root@dm900:/tmp# ./astra -v
./astra: error while loading shared libraries: libdvbcsa.so.1: cannot open shared object file: No such file or directory
root@dm900:/tmp#
 

mouadhada

Senior Member
Messages
190
I guess that libriaries are already there !

root@dm920:/tmp$ ./astra -v
Astra SM 0.2
root@dm920:/tmp$ ./t2mi_decap -v
./t2mi_decap: invalid option -- 'v'
error: usage: ./t2mi_decap OPTIONS -i <infile> -o <outfile>
options:
-p <plp_id>
-P <payload_pid>
-s <payload_pnr>
 

mouadhada

Senior Member
Messages
190
All bin are working with me but when I put a channel I don’t have anything in astra log.
As if it is not processed !
 

mouadhada

Senior Member
Messages
190
try this
1. in Menu - Setup Network WebInterface
"disable anti-hijacking and token-based security in web interface settings" (big thank you again @matt33 and @Rickk)
2. (all files with permission 755) create the abertis.service file in /etc/systemd/system and insert that
Code:
[Unit]
Description = ABERTIS service

[Service]
ExecStart = /ect/init.d/astra-sm &

[Install]
WantedBy = multi-user.target
3. install astra-sm and libaio from ipk
4. with command activate service with:
Code:
systemctl enable abertis.service
5. with command init 4 stop Enigma, replace with lamedb, init 3 and reboot
Done. Can use ciefp setting for lamedb ?
 
Last edited:

mouadhada

Senior Member
Messages
190
Within Ciefp setting I see the relevant keys in oscam logs !
So the http stream call the relevant abertis pid, but no picture !
any command to see astra log in syslog ?
 
Top