14 Replies - 3655 Views - Last Post: 15 May 2011 - 02:49 PM Rate Topic: -----

#1 m_alien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 13-May 11

Read XML from a device through a Serial Port

Posted 13 May 2011 - 07:49 AM

Anyone have any idea how to read XML into a vb.net program from a device

My current program can read in a continuous stream of data when initialized and I can send a command to retrieve the devices stored data, I also have within the same program code that will read an XML file and populate from controls.

I have two separate idea's right now that I'm trying to merge into one

I want to read in XML and populate my controls. I'm aware of delegate and Invoke but I'm having a hard time working them into my XML portion or the opposite "working my XML into my serial port class".

Is This A Good Question/Topic? 0
  • +

Replies To: Read XML from a device through a Serial Port

#2 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 386
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Read XML from a device through a Serial Port

Posted 14 May 2011 - 12:20 AM

What do you get on the serial port? You might get ASCII values or chars. Either way you have two choices:
1. save all data to a string and manipulate that string.
2. save it to a file and then pass the path to your XML file reader method.
Was This Post Helpful? 0
  • +
  • -

#3 m_alien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 13-May 11

Re: Read XML from a device through a Serial Port

Posted 14 May 2011 - 07:49 AM

Thanks for the reply

The data that I'm getting in is all XML tags. I'm pretty sure i could do this with string manipulation, but since the data is coming in as XML tags I thought there might be a more elegant solution.

What that solution is I'm not really sure. To get somewhat acquainted with reading XML I did another small program that will read from an XML file and populate controls using XML literals syntax. I thought is was actually pretty elegant and clever of myself, but I have no idea how to move from reading an XML file to reading in from the serial port. Either way I'm open to any other suggestions or methods.

Thanks again
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Read XML from a device through a Serial Port

Posted 14 May 2011 - 08:04 AM

The XmlDocument class has a LoadXml(<string>) method for building an Xml document by a string.
Was This Post Helpful? 1
  • +
  • -

#5 m_alien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 13-May 11

Re: Read XML from a device through a Serial Port

Posted 14 May 2011 - 08:04 PM

Thanks for the reply hawk

I've been trying to get this work for about a week, using syntax from invoke and delegate "in order to read in from a serial port" but I haven't really made much headway.

Could you possible post a way I could work work this into my program.
Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Read XML from a device through a Serial Port

Posted 14 May 2011 - 08:35 PM

The dataReceived event is happening on a different thread. What framework are you on - cause the answer differs?
Was This Post Helpful? 0
  • +
  • -

#7 m_alien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 13-May 11

Re: Read XML from a device through a Serial Port

Posted 15 May 2011 - 10:37 AM

4.0
Was This Post Helpful? 0
  • +
  • -

#8 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Read XML from a device through a Serial Port

Posted 15 May 2011 - 11:48 AM

My guess is your trying to access a control in the dataReceived Event. This goes in your dataReceived event.

Me.Invoke(Sub()
          <controlname>.<Property> = <data returned here>
          End Sub)


Don't you just love 4.0!
Was This Post Helpful? 0
  • +
  • -

#9 m_alien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 13-May 11

Re: Read XML from a device through a Serial Port

Posted 15 May 2011 - 12:13 PM

I don't know about love, it's deffinatly different, I can see why they did somethings but others are like why did they change that, I just keep in mind they change stuff to add more functionality somehow,

At least that's what I've conviniced myself of lol.

Thanks for the help hawk.
Was This Post Helpful? 0
  • +
  • -

#10 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Read XML from a device through a Serial Port

Posted 15 May 2011 - 12:24 PM

Well this just simplifies having to create a delegate and call this code in a diff sub - we can now execute what we want right here. I think it keeps your brain on track and not having to jump around for all the subs and where they are located. Anyway hope we answered your question.
Was This Post Helpful? 0
  • +
  • -

#11 m_alien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 13-May 11

Re: Read XML from a device through a Serial Port

Posted 15 May 2011 - 12:41 PM

Yeah I know what you mean

I understand how to get the string data into the one control, it's the many controls and data broken up that's stalling me
Was This Post Helpful? 0
  • +
  • -

#12 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Read XML from a device through a Serial Port

Posted 15 May 2011 - 01:35 PM

If it's Xml, just load an XmlDocument like I showed above, then parse the it.
Was This Post Helpful? 0
  • +
  • -

#13 m_alien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 13-May 11

Re: Read XML from a device through a Serial Port

Posted 15 May 2011 - 02:06 PM

Do I load my XmlDoc in place of where my ReceivedData variable goes.

So instead of

ReceivedData = (NewSerialPort.SerialPort1)

Insert my xmlDoc load string business there instead


Dim Xdoc as New XDoc = (NewSerialPort.SerialPort1)?

If this is the case I feel like a fool lol
Was This Post Helpful? 0
  • +
  • -

#14 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Read XML from a device through a Serial Port

Posted 15 May 2011 - 02:40 PM

Dim xmlDoc As New XmlDocument
xmlDoc.LoadXml(<dataReceived>)

Was This Post Helpful? 1
  • +
  • -

#15 m_alien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 13-May 11

Re: Read XML from a device through a Serial Port

Posted 15 May 2011 - 02:49 PM

Okay

This is making pretty good sense now, I can't wait to get back to my computer to try this out,

Thank you so much for the help today hawk.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1