Parsing Strings From a serial portManipulate xml through linq

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi, thanks for taking the time to read my post. I am currently working on a project where I must capture serial port data which is usually displayed on a VT100 terminal from a Microcontroller, I have tried and failed using a regex to format the data correctly
as I must get the name of the function and its value, ideally in to an array of object to utilizes in the code. For the purpose of illustration please see the sample of data I am working with;
<pre> : 0E 1 IGBT Alarm #1 : 1E 1 IGBT Alarm #2 : 1E <br/>
0 IGBT Alarm #3 : 1E 0 IGBT Alarm #4 : 1E 0 IGBT Alarm #5 : 1E <br/>
1 IGBT Alarm #6 : 1E 1 IGBT Alarm #7 : 1E 0 Digital Input #1 : 0EConfig Input #1 : 0 <br/>
Digital Input #2 : 0EConfig Input #2 : 0 Digital Input #3 : 0EConfig Input #3 : 0 Digital Input #4 : 0EHardware Key #1 : 0 Digital Input #5 : 0EHardware Key #2 : 0 Digital Input #6 : 0EWatchdog Status : 1 Digital Input #7 : 0ECard Type : 1 Reverse Battery
[/code]
<


Is it possible to update the following xml structure through linq.
I want to add UnitTest, TestList, TestEntry and UnitTestResults elements through code.

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; UTF-8<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; TestRun <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; xmlns<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://microsoft.com/schemas<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestDefinitions<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; UnitTest <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Test1<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T1<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Execution <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E1<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; UnitTest<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; UnitTest <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Test2<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T2<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Execution <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E2<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; UnitTest<span style="color:Blue; >
:
:

<span style="color:Blue; </<span style="color:#A31515; TestDefinitions<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestLists<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestList <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; List1<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L1<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; TestList <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; List2<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L2<span style="color:Black; " <span style="color:Blue; />
:
:

<span style="color:Blue; </<span style="color:#A31515; TestLists<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestEntries<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestEntry <span style="color:Red; testId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T1<span style="color:Black; " <span style="color:Red; executionId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E1<span style="color:Black; " <span style="color:Red; testListId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L1<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; TestEntry <span style="color:Red; testId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T2<span style="color:Black; " <span style="color:Red; executionId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E2<span style="color:Black; " <span style="color:Red; testListId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L2<span style="color:Black; " <span style="color:Blue; />
:
:
<span style="color:Blue; </<span style="color:#A31515; TestEntries<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Results<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; UnitTestResult <span style="color:Red; executionId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E1<span style="color:Black; " <span style="color:Red; testId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T1<span style="color:Black; " <span style="color:Red; testName<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Test1<span style="color:Black; " <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Output<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ErrorInfo<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Message<span style="color:Blue; >Hi<span style="color:Blue; </<span style="color:#A31515; Message<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; ErrorInfo<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Output<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; UnitTestResult<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Results<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Results<span style="color:Blue; >
:
:
<span style="color:Blue; </<span style="color:#A31515; TestRun<span style="color:Blue; >

[/code]
<hr class="sig Regards,<br/>
http://jaydeeppatil.co.cc Jaydeep

View the full article
 
Back
Top