Canada
Asked

Skills Sendserial Syntex Help.

Hello,

I have been using EZ-Script for sendserial commands because I'm not much of a programmer to make my own skills. But i would like to convert my ez-scripts to skills. i have finished the tutorial but am having some syntex problems with Visual Studio.

EZ-Script Syntex: SendSerial( d0, 57600, 0xf0, 0xaa, 0x05, 0x04, 0x55)

User-inserted image?


Related Hardware EZ-B IoTiny

ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

PRO
Synthiam
#1  

Awesome - making a robot skill is fun and super fast. Specifically when you build it for what you want that others can use.

The great thing about Visual Studio is Code Complete (Intellisense). When you start typing, it will display parameters for you to select from. Here's an example when typing for SendSerial on the Primary EZB

User-inserted image

So a completed example using the above syntax would be... User-inserted image


    void SendSerialTest() {

      EZBManager.PrimaryEZB.Uart.SendSerial(EZ_B.Digital.DigitalPortEnum.D0, EZ_B.Uart.BAUD_RATE_ENUM.Baud_57600, new byte[] { 0xf0, 0xaa, 0x05, 0x04, 0x55 });
    }

I see you're using the EZBManager's SendSerial, which will parse the text, but not as efficient as the example I gave above. Using the SendSerial helper that you discovered, the syntax would pass the port as a string. It isn't as efficient nor is it as expandable as using the above version. But for example it would look like...

User-inserted image


    void SendSerialTest() {

      EZBManager.SendSerial("d0", EZ_B.Uart.BAUD_RATE_ENUM.Baud_57600, new byte[] { 0xf0, 0xaa, 0x05, 0x04, 0x55 });
    }


I'd recommend the first example I displayed... because that way you can specify the port as an enum. Your config screen can use the ARC.UCForms.UC.UCPortButton user control on the config form. You can get the selected port with....


    void SendSerialTest() {

      var selectedPort = ucPortButton.PortDigital2;
    }

and set the port with....


      ucPortButton.SetConfig((EZ_B.Digital.DigitalPortEnum)_cf.STORAGE["SerialPort"]);

#2  

I don't pretend to understand most of the coding for making a skill using Visual Studio Code but I'm trying to understand some of the basics. When I use a Uart port for sendserial commands using EZ-Script I first have to initialize the uart port. Does the corrected syntax that DJ provided do that? I think that is what he means when he says specify the port as an enum?

Just for reference to what I'm asking, My ez script to initialize the uart port on the EZB looks like this:

UARTInit(0, 0, 9600 ) #Turn on EZB 0 Uart #0 port

Then I send the command to the Sabertooth/Kangaroo:

uartWrite(0, 0, "1, start", 0x0d) #Start ST/Roo channel 1 on EZB 0
PRO
Synthiam
#3  

DAve, send serial and uartwrite are different.

You do not initialize anything with sendserial

#4  

OK, I've got more to learn I guess. LOL. I seemed to be confusing sendserial with simple serial commands I send through the Uart port.

PRO
Synthiam
#5  

Yah, sendserial uses software to fake sending serial. It’s called bitbang. It can’t receive but it can send.

the uart commands use the built in hardware uart which needs to be initialized. This is because the hardware uart has a buffer to receive data.

the uart is far more reliable than the sendserial.

#6   — Edited

Thanks for the lesson. It's more clear now.

So the old version 3 ezb must have used bitbang to send serial? That version could send but not receive.

PRO
Synthiam
#7  

That’s right - the v3 did not have a uart for receiving serial data.

#8  

Thanks DJ. I never put the two together. I sometimes wondered why a digital pin could send but not receive serial data. It's great to learn new things.