boyracer38 Posted November 2, 2004 Report Share Posted November 2, 2004 Hi all, currently stuck on the following I am doing a labview assingnment that entails duplex serial port communication between 2 VIs. So I write a string to the com port on one machine/vi, then on the other read the stream one byte at a time (i've included start and stop bits for the packet) - so the other machine reads a start bit, then loops round and reads each byte at a time from the stream until it hits the stop bit and then this is where the problem starts with auto indexing on, the while loop then chucks out an array of all the bytes that have been read how would I go about turning this array into a string? As i need to do string manipulation etc on it? hope someone can help many thanks Quote Link to comment
Jimmy-Chen Posted November 3, 2004 Report Share Posted November 3, 2004 I think you have several ways to do this.....Array to String. 1)Use Array "To Spreadsheet String Functions"(Functions>>String>>Array To Spreadsheet String). 2)Use For loop and Shift Register. See attach image. Hope this can help you. Quote Link to comment
boyracer38 Posted November 3, 2004 Author Report Share Posted November 3, 2004 I think you have several ways to do this.....Array to String.1)Use Array "To Spreadsheet String Functions"(Functions>>String>>Array To Spreadsheet String). 2)Use For loop and Shift Register. See attach image. Hope this can help you. 2535[/snapback] thanks Jimmy using a shift register i've managed to extract the read string from the start and stop bits does this look like the best way to do this? one of my lecturers suggested the use of a local variable, but i'm not grasping how to do this and achieve the same results. Many thanks Quote Link to comment
xseadog Posted November 3, 2004 Report Share Posted November 3, 2004 thanks Jimmyusing a shift register i've managed to extract the read string from the start and stop bits does this look like the best way to do this? one of my lecturers suggested the use of a local variable, but i'm not grasping how to do this and achieve the same results. Many thanks 2538[/snapback] Hi boyracer why read one bit at a time ?? Use read bye count vi ! With regard to you block diagram- you are assuming that the serial port init occurs before you read loop Use sequence to ensure that occurs :worship: Also recommand that you add a short delay so that initialisation of port complete before event. At present you loop structure is hogging CPU process time, put a wait in the loop with say 20ms (experiment) chow xseadog Quote Link to comment
boyracer38 Posted November 3, 2004 Author Report Share Posted November 3, 2004 hey xseadog thanks for the idea - will try it out i'd read one byte at a time because before i tried to just do a 'serial port read' without a 'bytes at serial port' and sometimes the string was getting read in a funny order :thumbdown: so, to add a delay, would i put that in the sequence that does the read? also, I want to add something so that it writes back to the other machine as well. As i want to read string from serial port, do stuff with it and alter settings on front panel accordingly then write back the change of settings and other things. Fundamentally, both machines will need to read and write - duplex communication over serial. Do i just add another sequence below this so that they run in unison? sorry to ask so many questions - got a big assignment and this is a small foundation of it, without which I cannot progress many many thanks PS I am not actually 'boyracer38' - he is my housemate, I did register as bUrGe and Michael Burgess, neither of which I received an activation e-mail for cheers, Mike Quote Link to comment
Mark Balla Posted November 4, 2004 Report Share Posted November 4, 2004 The simplest way that I've found to concatenate a string array is to just wire the array to a concatenate primitive. As far as the serial reading I've developed a serial read vi that not only used the buffer count but also includes timing functions and other useful items. I also included a 7.0 version Download File:post-584-1099547750.llb Download File:post-584-1099548148.llb Quote Link to comment
aledain Posted November 4, 2004 Report Share Posted November 4, 2004 Check out this link for a robust serial reader/writer ... SerialComms .. it'll give you some pointers if you burrow into the code. cheers, Alex Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.