How Many Bytes to read with Serial Communication?

A Discussion about Mate to computer serial communications.

Moderator: OutBack Moderator Team

How Many Bytes to read with Serial Communication?

Postby helloworld on Tue Jan 31, 2012 1:46 pm

Hello,

I am currently working with the outback mate in order to remotely retrieve data. The location from which I am receiving data is using a outback HUB which has 4 FXs, 1 MX, and 1 Flexnet DC connected to it. I have developed a read protocol in LabVIEW 2009 which simply reads in the data through serial communication and stores the data in a file. I have successfully tested my protocol and it is functioning well to a certain point in time. I beginning reading data and after a few readings the data begins to be read out of order or it begins reading a new string half way. I am not sure if I have the timing off or I am not reading the appropriate amount bytes. I am aware that each status page is compose of 49 bytes and I have confirmed this when I read in the data.

My question is how do I modify the amount of bytes I should be reading so the data is not read out of order? How does having the HUB affect when and how the status pages of the FX, MX, and FLEXnet DC are sent?

Thank you in advance for any help you can provide.
helloworld
Junior Member
 
Posts: 3
Joined: Tue Jan 31, 2012 1:30 pm

Re: How Many Bytes to read with Serial Communication?

Postby helloworld on Tue Jan 31, 2012 2:20 pm

I just want to mention I am new with this whole system so if you need something to be further explain let me know and I will try my best to explain it.

Thanks
helloworld
Junior Member
 
Posts: 3
Joined: Tue Jan 31, 2012 1:30 pm

Re: How Many Bytes to read with Serial Communication?

Postby tallgirl on Wed Feb 22, 2012 12:30 pm

Check all your serial connections. That's all I can say.

The only possible explanation is your serial port and/or USB to serial adapter has issues.
Julie in Texas

greenMonitor(tm) for OutBack Power Technologies systems from greenHouse Gas and Electric. Learn more now!
User avatar
tallgirl
OutBack Emperor
 
Posts: 4253
Joined: Wed Sep 26, 2007 9:59 am
Location: Austin, TX
My RE system: 16 Kyocera KC175GT (2,800 watts DC), MX-60, 2 OutBack GVFX3648, 24 GC2 batteries (6v @ 215AH), 14 Pantheon-based ACPV modules (3,200 watts DC), La Crosse Technologies WS2310 Weather Station, greenLogger Sensors environmental monitor, WattNode watt-hour meter, greenLogger Lite data logger.

Re: How Many Bytes to read with Serial Communication?

Postby jnh on Thu Feb 23, 2012 6:32 pm

Rather than always reading in a set number of bytes, it's better to read up until the first "newline" character (0x0A), using something like C's fgets() function with some reasonable maximum line length >=50, if your software supports that. This way any line noise, etc. causing a corrupt or incomplete read will only clobber a line or two, rather than getting you out of alignment and propagating through to all subsequent reads.

Also, be sure to use that provided checksum byte at the end (described in the Mate Serial Comm. Guide) to verify each line before accepting it as valid data. It would be good to have some provision in your code for dealing with missing/invalid samples in a reasonable way, perhaps interpolating from the nearest valid lines on either side of the dropout.

Not that you should be getting dropouts & corruption in the first place (the one time I had such trouble it was due to a flaky USB-Serial dongle, like Julie mentioned), but it's good to be prepared for them just in case.
jnh
OutBack Guru
 
Posts: 286
Joined: Fri Jun 01, 2007 11:56 am
Location: St. Augustine, FL, US
My RE system: GVFX-3524, MX-60, ~1600W PV in assorted panels
300 Ah AGMs @ 24V, 150 Ah @ 12V
Hub4, Mate, FNDC, Midnite E-Panel, homebrew DC-DC crossfeed to 12V system, Honda EU-1000i backup generator


Return to Mate Serial Communications

Who is online

Users browsing this forum: No registered users and 1 guest