Prev: Best way to Read BMP image and write data (in Hex) to file
Next: convert bit-stream to pulse waveforms
From: Ricky on 25 Mar 2010 21:01 I am to build a module in Simulink which transmit some data over serial using the Quatechs ESC-100 serial card. I found that the transmission (and receiving) terminates with a null character or 0x00. At first I thought the problem was limited to the FIFO used by the ESC-100 modules. So I have created an alternative module using ESC-100 internal blocks without the FIFO. But further testing shows that 0x00 is still not being transmitted and terminates the transmission until the next non-zero value byte. Since my data I have to transmit contains 0x00, is there a way around this problem? Cheers.
From: Trent Jarvi on 29 Mar 2010 18:25 "Ricky " <rtiong(a)gmx.com> wrote in message news:hoh10j$95g$1(a)fred.mathworks.com... >I am to build a module in Simulink which transmit some data over serial >using the Quatechs ESC-100 serial card. > > I found that the transmission (and receiving) terminates with a null > character or 0x00. At first I thought the problem was limited to the FIFO > used by the ESC-100 modules. So I have created an alternative module using > ESC-100 internal blocks without the FIFO. But further testing shows that > 0x00 is still not being transmitted and terminates the transmission until > the next non-zero value byte. > > Since my data I have to transmit contains 0x00, is there a way around this > problem? > > Cheers. > Yes. NULL is an unusual case for the string based functions. I think you will want to use FREAD and FWRITE . The following is with a loopback connection. >> fwrite(s,['hello world' char(0)]); >> fread(s,12) ans = 104 101 108 108 111 32 119 111 114 108 100 0 >> char(ans)' ans = hello world
From: Gordon Weast on 30 Mar 2010 10:00
Ricky, You didn't say, but I suspect you're working with xPC Target blocks. Your mention of the internal blocks without FIFO makes me think that. If you change the data type in the XMT port from NULL terminated uint8 to 'count+uint16' and then put the count of the number of items to send in the first element of the vector, it will send a NULL byte. The uint8 data type is intended to mimic a C string that contains ASCII coded data. The uint16 data type is intended for binary send and receive. You'll have to use a data type conversion block to take a uint8 vector and convert it to uint16, with one byte used in each 16 bit element. Then use a mux block to attach the count to the front. Also, these blocks only work on the target machine, not on the host. Gordon Weast xPC Target Development The MathWorks Ricky wrote: > I am to build a module in Simulink which transmit some data over serial > using the Quatechs ESC-100 serial card. > > I found that the transmission (and receiving) terminates with a null > character or 0x00. At first I thought the problem was limited to the > FIFO used by the ESC-100 modules. So I have created an alternative > module using ESC-100 internal blocks without the FIFO. But further > testing shows that 0x00 is still not being transmitted and terminates > the transmission until the next non-zero value byte. > > Since my data I have to transmit contains 0x00, is there a way around > this problem? > > Cheers. |