Problems with synchron channel / MOST

Hi!

I´m having problems with the synchron channel.
The following example should work as a receiver for stream data.
When I´m starting the receiver, it always gets a pulse and writing
the data (given by the 2nd parameter from write) in the file (with
name FILE_NAME) - BUT there isn´t any transceiver process anywhere
runing.

Here my ask:
Where is the error? Why gets the MsgReceivePulse a pulse?
Lacks something?


chid = ChannelCreate( 0 );
coid = ConnectAttach( 0, 0, chid, _NTO_SIDE_CHANNEL, 0 );
fptr = creat( FILE_NAME, S_IWUSR );

most_connect(MOST_SYNC_CONNECTION, 0, &most_connector);
sync_fd = most_file_descriptor(most_connector);

SIGEV_PULSE_INIT ( &msg.event, coid, SIGEV_PULSE_PRIO_INHERIT,
MY_PULSECODE_SYNC, 0);

memset(cfg, 0, sizeof(cfg));
cfg->sync_direction = SYNC_RX;
cfg->segs = 2;
cfg->seg_size = 1024 * 64;
cfg->channels = 4;
cfg->event = msg.event;

most_stream_alloc(most_connector, cfg);

most_stream_start(most_connector, cfg);

buf_size=cfg->seg_size;

while (1)
{
if (MsgReceivePulse(chid, &pulse, sizeof(pulse), NULL) != -1)

{
printf(“streamRx → Pulse\n”);
write(fptr, &cfg->virt_addr + (pulse.value.sival_int *
buf_size), buf_size);
}
}

close( fptr );

Thanx!

MOSTMAN wrote:

Hi!

I´m having problems with the synchron channel.
The following example should work as a receiver for stream data.
When I´m starting the receiver, it always gets a pulse and writing
the data (given by the 2nd parameter from write) in the file (with
name FILE_NAME) - BUT there isn´t any transceiver process anywhere
runing.

Here my ask:
Where is the error? Why gets the MsgReceivePulse a pulse?
Lacks something?


chid = ChannelCreate( 0 );
coid = ConnectAttach( 0, 0, chid, _NTO_SIDE_CHANNEL, 0 );
fptr = creat( FILE_NAME, S_IWUSR );

most_connect(MOST_SYNC_CONNECTION, 0, &most_connector);
sync_fd = most_file_descriptor(most_connector);

SIGEV_PULSE_INIT ( &msg.event, coid, SIGEV_PULSE_PRIO_INHERIT,
MY_PULSECODE_SYNC, 0);

memset(cfg, 0, sizeof(cfg));
cfg->sync_direction = SYNC_RX;
cfg->segs = 2;
cfg->seg_size = 1024 * 64;
cfg->channels = 4;
cfg->event = msg.event;

most_stream_alloc(most_connector, cfg);

most_stream_start(most_connector, cfg);

buf_size=cfg->seg_size;

while (1)
{
if (MsgReceivePulse(chid, &pulse, sizeof(pulse), NULL) != -1)

{
printf(“streamRx → Pulse\n”);
write(fptr, &cfg->virt_addr + (pulse.value.sival_int *
buf_size), buf_size);
}
}

close( fptr );

Thanx!

The reason is because sync frames are constantly coming in, and you’re
sampling the content of those channels each MOST frame (regardless of if
a transmitter is filling them or not). This is the nature of SYNC
transmission.

\

Cheers,
Adam

QNX Software Systems
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

Hi Adam,

thanx a lot for your answer, but there is a next problem:
If I start the receiver to write all data incoming from most bus to a

file, the file doesn´t look like manipulated/written by saving the
datas coming from bus in it.
Have I used the wrong virtuell address? Where could be the error. Or
is the writing process
to slow and comes to late when the buffer is already empty?
Thanx !!

#include <stdio.h>
#include <stdlib.h>
#include <hw\most\most.h>
#include <hw\most\most_driver.h>
#include <sys/neutrino.h>
#include <sys/siginfo.h>

#define MAX_SIZE 1000
#define MY_PULSECODE_SYNC _PULSE_CODE_MAXAVAIL
#define FILE_NAME “file.txt”

int main(int argc, char *argv[]) {

int chid, coid, sync_fd, rtn, buf_size, read_len, data_size, fptr;
struct sigevent event;
struct _pulse pulse;
most_stream_config_t *cfg=(most_stream_config_t *)
malloc(MAX_SIZE);
most_connection_t *most_connector=(most_connection_t *) malloc
(MAX_SIZE);

chid = ChannelCreate( 0 );
coid = ConnectAttach( 0, 0 , chid, _NTO_SIDE_CHANNEL, 0 );
fptr = open( FILE_NAME, O_RDONLY );
most_connect(MOST_SYNC_CONNECTION, 0, &most_connector);

SIGEV_PULSE_INIT ( &event, coid, SIGEV_PULSE_PRIO_INHERIT,
MY_PULSECODE_SYNC, 0);

memset(cfg, 0, sizeof(cfg));
cfg->sync_direction = SYNC_TX;
cfg->segs = 2;
cfg->seg_size = 1024;
cfg->channels = 4;
cfg->event = event;

most_stream_alloc(most_connector, cfg);

most_stream_start(most_connector, cfg);

buf_size=cfg->seg_size;

while (1)
{
if (MsgReceivePulse(chid, &pulse, sizeof(pulse), NULL) != -1)

{
read_len = read(fptr, (char*) (cfg->virt_addr) +
(pulse.value.sival_int * buf_size), data_size);
}
}
most_stream_stop(most_connector, cfg);
most_stream_free(most_connector, cfg);

close( fptr );
printf(“END\n”);

return EXIT_SUCCESS;
}

MOSTMAN wrote:

Hi Adam,

thanx a lot for your answer, but there is a next problem:
If I start the receiver to write all data incoming from most bus to a

file, the file doesn´t look like manipulated/written by saving the
datas coming from bus in it.
Have I used the wrong virtuell address? Where could be the error. Or
is the writing process
to slow and comes to late when the buffer is already empty?
Thanx !!

You program looks like a producer/transmitter not a consumer/receiver
you mentioned above (since the direction is TX and you’re reading,
rather than writing).

One thing I notice you’re missing is a call to most_sync_out_connect()
before doing the most_stream_start. This call allows you to program the
synchronous routing engine in the OS8104 to move data to the channels
you’ve setup prior. If the routing isn’t setup properly, you’ll not get
any sound/data.

FYI - You should be using the NetServices API, not the most_*() as it’s
deprecated.

-Adam

#include <stdio.h
#include <stdlib.h
#include <hw\most\most.h
#include <hw\most\most_driver.h
#include <sys/neutrino.h
#include <sys/siginfo.h

#define MAX_SIZE 1000
#define MY_PULSECODE_SYNC _PULSE_CODE_MAXAVAIL
#define FILE_NAME “file.txt”

int main(int argc, char *argv[]) {

int chid, coid, sync_fd, rtn, buf_size, read_len, data_size, fptr;
struct sigevent event;
struct _pulse pulse;
most_stream_config_t *cfg=(most_stream_config_t *)
malloc(MAX_SIZE);
most_connection_t *most_connector=(most_connection_t *) malloc
(MAX_SIZE);

chid = ChannelCreate( 0 );
coid = ConnectAttach( 0, 0 , chid, _NTO_SIDE_CHANNEL, 0 );
fptr = open( FILE_NAME, O_RDONLY );
most_connect(MOST_SYNC_CONNECTION, 0, &most_connector);

SIGEV_PULSE_INIT ( &event, coid, SIGEV_PULSE_PRIO_INHERIT,
MY_PULSECODE_SYNC, 0);

memset(cfg, 0, sizeof(cfg));
cfg->sync_direction = SYNC_TX;
cfg->segs = 2;
cfg->seg_size = 1024;
cfg->channels = 4;
cfg->event = event;

most_stream_alloc(most_connector, cfg);

most_stream_start(most_connector, cfg);

buf_size=cfg->seg_size;

while (1)
{
if (MsgReceivePulse(chid, &pulse, sizeof(pulse), NULL) != -1)

{
read_len = read(fptr, (char*) (cfg->virt_addr) +
(pulse.value.sival_int * buf_size), data_size);
}
}
most_stream_stop(most_connector, cfg);
most_stream_free(most_connector, cfg);

close( fptr );
printf(“END\n”);

return EXIT_SUCCESS;
}


Cheers,
Adam

QNX Software Systems
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

Hello Adam!

Thanks for your answer. Sorry for posting the wrong program. You write
me I should use
the command
most_sync_in_connect(most_connection_t *__connection, int __num,
uint8_t *__chlist, uint8_t *__port, uint8_t *__byte);
before most_stream_start…but in the documentation there is no
description of the parameters of this function…How must
I initialize this parameters, which values get they?
Another problem: You also write I should use the netservices api, but
the netservices api from oasis is only available for windows, isn’t
it?

Thanks a lot, Mostman

Hello again Adam,

I have seen that there are the needed libs, but I didn’t find the
headerfile “netservices_qnx.h” and so I disregarded this
option of using the netservices. Where do I find the docu for the
command “most_sync_in_connect” and so on?
The docu of the kit didn’t describe this part. For every information
I’ll be very gratefully.

Thank you!!!

I received the following solution via email:

He needs to do sync channel setup via:

most_sync_allocate() - which given a most_connection_t (SYNC), and
number of channels to allocate will return a channel list (actual
channel numbers allocated on the MOST network).

Then a call to most_sync_in_connect() with a control connection (which

he’ll need to setup just like he did his sync connection), # of
channels
and the channel list you got from most_sync_allocate(), plus a port
and
byte list.

Typically it would be declared like:

uint8_t portlist[4];
uint8_t bytelist[4];

And filled in as:

for(i=0 ; i<4; i++) {
portlist = cfg.srcdata_.Port_SF;
#ifdef AUDIO_DATA_IS_LITTLE_ENDIAN
bytelist = cfg.srcdata[(i%2) ? i-1 : i+1].Byte;
#else
bytelist = cfg.srcdata.Byte;
#endif


The cfg struct is setup by the call to most_stream_alloc() which he
already does in his program.

So most_sync_allocate() will allocate the channel space in the MOST
bus,
and most_sync_in_connect will setup the Sync routing engine in the
8104
to route the data out to the most bus_