How to define USB serial port ID (MacBook) to send a string to arduino uno

Typically: "How do I... ", "How can I... " questions
Post Reply
xescbdn
Posts: 11
Joined: 14 Jun 2018, 17:54

How to define USB serial port ID (MacBook) to send a string to arduino uno

Post by xescbdn » 23 Jun 2018, 19:00

Hello,

I am trying to communicate with arduino uno to send information for servo moving drived by arduino but I am having an error that I think is related with serial port definition....

How I should define the port in the script?
this is the code I am using for this purpose:

--defining the serial port number
port=sim.getScriptSimulationParameter(sim.handle_self,'serialPortNumber')
--portNumber="\\\\.\COM4"..port
--could be defined as followed
portNumber=[[\\\\.\usbmodemFD121]]
baudrate=9600
serial=sim.serialOpen(portNumber,baudrate)


thanks in advance

coppelia
Site Admin
Posts: 6747
Joined: 14 Dec 2012, 00:25

Re: How to define USB serial port ID (MacBook) to send a string to arduino uno

Post by coppelia » 27 Jun 2018, 09:45

Hello,

not sure 100% anymore, but isn't the string something like \\.\portString?

Cheers

xescbdn
Posts: 11
Joined: 14 Jun 2018, 17:54

Re: How to define USB serial port ID (MacBook) to send a string to arduino uno

Post by xescbdn » 28 Jun 2018, 18:27

coppelia wrote:
27 Jun 2018, 09:45

not sure 100% anymore, but isn't the string something like \\.\portString?
No, this option returns "error".

In my case, I get no error message on console defining between brackets just same definition I got on Arduino IDE:

portNumber=[[/dev/cu.usbmodemFD121]] --MacBook port definition
(for windows I do like --> portNumber=[[COM3]] )

Unfortunately, I get "Child Script Abort" message but I think is related with what type of data Arduino is receving (byte, string, etc...) any clue ???

thanks

coppelia
Site Admin
Posts: 6747
Joined: 14 Dec 2012, 00:25

Re: How to define USB serial port ID (MacBook) to send a string to arduino uno

Post by coppelia » 04 Jul 2018, 05:49

The Child script abort message indicates that the child script is hanging, i.e. probably you are trying to read data on the port but no data (or not anymore) is available. Make sure to first call sim.serialCheck.

Cheers

Post Reply