"Rami AbouSleiman" <rdabousl@oakland.edu> wrote in message
<g1hngc$k10$1@fred.mathworks.com>...
> I am trying to send numbers from 0-65535 or 0-FFFF
through
> the serial port.
>
> I need to get the hex value on the other side but I am
> getting garbage how can I fix it?
>
> I am using fwrite() command/
>
> For example if I send a 0 I get a 00 08 00 on the
otherside.
> Thanks in advance
> Rami
> rdabousl@oakland.edu
I'm guessing the data type is being confused. Try explicity
defined the data type as 'uint8' as an argument to fwrite:
fwrite(fid,[0 1 2 3 4 5 6 7],'uint8')
You could also try casting your data,
fwrite(fid,uint8(0:65535))
"Rami AbouSleiman" <rdabousl@oakland.edu> wrote in message
news:g1hngc$k10$1@fred.mathworks.com...
>I am trying to send numbers from 0-65535 or 0-FFFF through
> the serial port.
>
> I need to get the hex value on the other side but I am
> getting garbage how can I fix it?
>
> I am using fwrite() command/
>
> For example if I send a 0 I get a 00 08 00 on the otherside.
> Thanks in advance
> Rami
> rdabousl@oakland.edu
"Trent Jarvi" <tjarvi@mathworks.com> wrote in message
<g1hva4$duo$1@fred.mathworks.com>...
>
> "Rami AbouSleiman" <rdabousl@oakland.edu> wrote in
message
> news:g1hngc$k10$1@fred.mathworks.com...
> >I am trying to send numbers from 0-65535 or 0-FFFF
through
> > the serial port.
> >
> > I need to get the hex value on the other side but I am
> > getting garbage how can I fix it?
> >
> > I am using fwrite() command/
> >
> > For example if I send a 0 I get a 00 08 00 on the
otherside.
> > Thanks in advance
> > Rami
> > rdabousl@oakland.edu
>
> s=serial('/dev/ttyS0');
> s.OutputBufferSize=65536*16;
> fopen(s);
> fwrite(s,[0:65535],'uint16');
>
>
Thank you Trent for the reply,
but my hex received is now reversed , life i get EF FF for
65519,
any clue?
Thank you again
"Rami AbouSleiman" <rdabousl@oakland.edu> wrote in message
<g1i9qm$77e$1@fred.mathworks.com>...
> "Trent Jarvi" <tjarvi@mathworks.com> wrote in message
> <g1hva4$duo$1@fred.mathworks.com>...
> >
> > "Rami AbouSleiman" <rdabousl@oakland.edu> wrote in
> message
> > news:g1hngc$k10$1@fred.mathworks.com...
> > >I am trying to send numbers from 0-65535 or 0-FFFF
> through
> > > the serial port.
> > >
> > > I need to get the hex value on the other side but I am
> > > getting garbage how can I fix it?
> > >
> > > I am using fwrite() command/
> > >
> > > For example if I send a 0 I get a 00 08 00 on the
> otherside.
> > > Thanks in advance
> > > Rami
> > > rdabousl@oakland.edu
> >
> > s=serial('/dev/ttyS0');
> > s.OutputBufferSize=65536*16;
> > fopen(s);
> > fwrite(s,[0:65535],'uint16');
> >
> >
> Thank you Trent for the reply,
> but my hex received is now reversed , life i get EF FF
for
> 65519,
> any clue?
> Thank you again
FIXED just change the obj setting to bigEndian
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Disclaimer prior to use.