USB Slave - Arrays of Bytes & Integers

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
Woode
Posts: 10
Joined: Fri Dec 26, 2008 4:11 pm
Been thanked: 2 times
Contact:

ο»ΏUSB Slave - Arrays of Bytes & Integers

Post by Woode »

I think the Flowcode designers were trying to keep things simple with their various ‘Slave
Service Macro Parameters’. :roll:

Well, lets get a bit more complicated,
1. A string is an array of ASCII characters ie. an array of numbers.
2. An array of numbers is exactly that, an array of numbers.
3. An integer is number that can be represented by 2 bytes, so an array of integers of size ‘n’
is an array of Bytes twice that size.

Therefore the Service Parameter ‘Char, String’ will do everything that is needed. When the
‘service_macro’ is not used the Component Macros ‘Get String’ and ‘Get Byte’ are used. :lol:

1. The first byte is required as a command to select the correct program branch.
2. To transmit an array of numbers load directly into bDataOut array. Maximum 30 bytes.
3. To transmit an array of integers convert to two bytes and load into bDataOut array. Maximum 15 integers.
4. To Transmit a string convert to ASCII and load into bDataOut. (As in the original examples)

Note:- The 31/32 byte restriction is set in the component file USBSlave_code.c, #define
USB_EP1_IN_SIZE & USB_EP1_OUT_SIZE and char temp_str[31] = ""; (I have not tried increasing these)

At the other end the string has to be converted back to an array of bytes or integers.
When ‘Get String’ is used the string will include the first character/command byte and this has
to be removed or it will be displayed on the LCD.

A similar arrangement is used to transfer from the micro to the PC.

Delphi Demo Non Delphi users can run the EXE file to see the form layout and use the Word
version of the Delphi form to help translation to another language. (No complex programming included!)
Attachments
USB Arrays.zip
(213.54 KiB) Downloaded 356 times

Post Reply