View Full Version : Question about serial port

10-08-2010, 12:41 AM
I need help about serial port problems.
My program currently using treadmill as output device for position data and patriot for orientation data.
I`m using serial port module like most of this forum user using right now.
Matlab is my main program previously but i changed to vizard recently.
But i still use my original matlab m.file as reference.
This is my original matlab command.

#set serial port

#open port

#unlock treadmill and read data

#lock treadmill

I can set my treadmill to lock@unlock without no problem.
When i run the program no error occured but i received no output bytes from it.

print x
print 'received',len(x),'bytes'

input/output window show:
received 0 bytes

I`m pretty sure i got no mistake about serial setting or vizard command because i adjust the parameter for serial and i can lock@unlock my treadmil.
So i assume there must be a problem with the connection of terminator and inputbuffersize command in matlab.
I`m not really sure this is the cause for my problems but i dont know how to set this in vizard so i just assuming it.
Any menthod to changed this in vizard fot this 2 parameter to the way i changed it in matlab?
Or did i miss some commands?
I already tried this for this whole week but still no positive results.
Really need help.


10-11-2010, 12:13 PM
Are you reading in the data every frame through a function registered with vizact.ontimer or vizact.onupdate?

10-12-2010, 12:47 AM
Thanks for the reply Jeff.
Yes i already tried with both function vizact.ontimer and vizact.onupdate but still no positive results.
The input/output window still show results as below.

received 0 bytes

Is there any way i can put this command in vizard?


I`m not sure this have connection or this is the reason i cant get the data.
But i dont know how to change this command in vizard so i cant test it out.
I also searched about this two functions on website but seems all the results is just related to matlab.
I really need help about this.


10-18-2010, 12:31 AM
I try changed the command and sometimes got this in input/output command window.

received 1 bytes

What is the meaning of this?
Is it mean i got the data but can`t read it in vizard?
I supposed to get counts(numbers) but i got letter 'R' as my output.
I already tried about this serial for this last two weeks.
I really need help about this.


10-19-2010, 10:45 AM
Are you using the pySerial module? There should be no problem getting serial data in Vizard using that, it is just an add on for Python. The pySerial documentation should have examples of reading data into a Python script.

10-21-2010, 12:58 PM
It looks like you're mostly using the default values for the serial port parameters (baud rate, parity, and so on). It might be worth checking that these defaults are the same in pySerial as they are in Matlab...perhaps find out what values the Matlab serial port uses and explicitly set those in the Python code...

11-21-2010, 03:53 PM
I already solved this problem.