MQX_FILE_PTR IO stream for UART communication, mqx_file struct not accessable!

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX_FILE_PTR IO stream for UART communication, mqx_file struct not accessable!

592 Views
chelios
Contributor I

Hey guys, I am currently working with a Kinetis K70 processor which should communicate over UART5 with a Bluetooth Module. I use the IO serial port ittyf:  to regulate the UART. My communication works fine, i can send commands in blocking mode and the Bluetooth Module responds. Now I'm having trouble in receiving the response and buffering them since I have different commands for the Bluetooth Module and corresponding responses.

My code is set up as follows:

for the init:

static MQX_FILE_PTR p_bluetooth;

p_bluetooth = fopen(STRK_BLUETOOTH_SERIAL_PORT, (char *)(IO_SERIAL_RAW_IO));
ioctl(p_bluetooth, IO_IOCTL_SERIAL_SET_FLAGS, IO_SERIAL_RAW_IO);

I can send commands in blocking mode with while the RX is disabled:

char *command = cmd_buffer; // cmd_buffer contains the bluetooth command

fwrite(command , 1, strlen(command), p_bluetooth);

Afterwards RX is enabled:

My problem now is that the bluetooth module can respond with different strings of different length:

for the fread function I have to now how much characters exactly are in the p_bluetooth  filepointer

(Here an example for the first 10 characters, which works fine)

    fflush(p_bluetooth);
    char output_buffer[100];
    // read first 10 char into ouput_buffer
    fread(output_buffer, 1, 10, p_bluetooth);


For acessing the ungot_characters in the Filestream I tryed to acces the struct of MQX_FILE liike:

p_bluetooth->SIZE

p_bluetooth->LOCATION

p_bluetooth->UNGOT_CHARACTERS

Finally thoes values reamind zero all time even though I send and receive chars. I also can read and write to the file_ptr but nothing changes. I just want to now the number of chars in my p_bluetooth MQX_FILE_PTR which were not read but it seems there is no way to get that number. It seems that the mqx_file struct is not updated at all.

Did I miss something when I initialized it? I would be very glad for any help and advice.

Best regards,

Fabian

Labels (1)
0 Kudos
1 Reply

367 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Fibian:

I found one bug fix may be related to your issue.

pastedImage_1.png

This fix is release in MQX 4.2.0 (May 2015). What version you are using?  if it is an older version, I would suggest you update to the MQX 4.2.0 with patch 4.2.0.2 and try again.

Regards

Daniel

0 Kudos