Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Serial Port


Dams Jun 3, 2020 08:55 AM

Hi, In CrBasic there is any way to pass a comport address as a parameter of a function like this
function (portCom , ...)
serialopen (portCom, ....)
do something...
serialclose(portCom)
endfunction


JDavis Jun 3, 2020 10:31 PM

Most instructions can use a variable for the comport. I suggest declaring that variable as type Long. The comport names are predefined constants with integer values.


Dams Jun 4, 2020 05:49 AM

I try like this 

Function RS232_measurement(Port_Com as Long)  and Function RS232_measurement(Optional Port_Com as Long = 1) 

SerialOpen (Port_Com ,9600,0,1000,100)

...

end function

But the Crbasic return ComPort 0 illegal, parameter must be a constant integer


nsw Jun 5, 2020 08:28 AM

The "SerialOpen" instruction will not allow a variable for the ComPort parameter. Extract from CRBasic Help for the ComPort parameter for SerialOpen for the CR1000X :-

Type: Constant. For all instructions except SerialOpen, this parameter can also be a variable.

Log in or register to post/reply in the forum.