Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
libft.c File Reference
Copyright (C) 2007 Erik Andresen erik@vontaene.de. More...
Go to the source code of this file.
Functions | |
| long int | GetLibVersion () |
| doxygen ignore end | |
| char * | GetLibVersionStrg () |
| Returns lib version. | |
| long int | InitFtLib () |
| Library initialization (dummy) | |
| long int | InitFtUsbDeviceList () |
| Initiates and scans the USB bus. | |
| unsigned int | GetNumFtUsbDevice () |
| doxygen ignore end | |
| FT_HANDLE | GetFtUsbDeviceHandle (unsigned char Num) |
| doxygen ignore end | |
| FT_HANDLE | GetFtUsbDeviceHandleSerialNr (long int dwSN, long int dwTyp) |
| Gets the handle to a ft USB device with a specific serial number. | |
| FT_HANDLE | OpenFtCommDevice (char *sDevice, long int dwTyp, long int dwZyklus) |
| Gets the handle to a ft serial device. | |
| long int | GetFtDeviceTyp (FT_HANDLE hFt) |
| Returns type of the interface. | |
| long int | GetFtDeviceTypeString (FT_HANDLE hFt, char *dest, int len) |
| Returns a string that identifies the interface with human words. | |
| long int | OpenFtUsbDevice (FT_HANDLE hFt) |
| Opens this USB device. | |
| long int | CloseFtDevice (FT_HANDLE hFt) |
| Close the ft Device. | |
| long int | CloseFtLib () |
| Library deinitialization (dummy) | |
| long int | IsFtLibInit () |
| Check for Library initialization (dummy) | |
| long int | ResetFtTransfer (FT_HANDLE hFt) |
| reset outputs | |
| long int | StartFtTransferArea (FT_HANDLE hFt, NOTIFICATION_EVENTS *ev) |
| Starts the communication thread. | |
| long int | StartFtTransferAreaWithCommunication (FT_HANDLE hFt, NOTIFICATION_EVENTS *ignored) |
| Starts the communication thread. | |
| FT_TRANSFER_AREA * | GetFtTransferAreaAddress (FT_HANDLE hFt) |
| Get the transfer area. | |
| long int | StopFtTransferArea (FT_HANDLE hFt) |
| Stops the communication thread. | |
| long int | IsFtTransferActiv (FT_HANDLE hFt) |
| check if transfer is active. | |
| long int | DownloadFtProgram (FT_HANDLE hFt, long int dwMemBlock, unsigned char *pbArray, long int dwSize, long int dwParameter, unsigned char *pbName, long int dwNameLen) |
| Upload a program to the interface. | |
| long int | StartFtProgram (FT_HANDLE hFt, long int dwMemBlock) |
| Start a program. | |
| long int | StopFtProgram (FT_HANDLE hFt) |
| Stop a program. | |
| long int | DeleteFtProgram (FT_HANDLE hFt, long int dwMemBlock) |
| Delete a program. | |
| long int | SetFtProgramActiv (FT_HANDLE hFt, long int dwMemBlock) |
| Activate a program. | |
| long int | GetFtProgramName (FT_HANDLE hFt, long int dwMemBlock, long int dwSize, void *pName) |
| Get the name of a program. | |
| int | GetFtStatus (FT_HANDLE hFt, int *num) |
| Checks if a program is running. | |
| long int | GetFtFirmware (FT_HANDLE hFt) |
| Get the firmware number of this interface. | |
| char * | GetFtFirmwareStrg (FT_HANDLE hFt) |
| Get the firmware number of this interface. | |
| long int | GetFtSerialNr (FT_HANDLE hFt) |
| Get the serial number of this interface. | |
| char * | GetFtSerialNrStrg (FT_HANDLE hFt) |
| Get the serial number of this interface. | |
| long int | CloseAllFtDevices () |
| Close all ft devices. | |
| long int | SetFtDistanceSensorMode (FT_HANDLE hFt, long int dwMode, long int dwTol1, long int dwTol2, long int dwLevel1, long int dwLevel2, long int dwRepeat1, long int dwRepeat2) |
| Set the inputs D1 and D2 to distance oder voltage measuring. | |
| long int | SetRFMode (FT_HANDLE hFt, long int frequency, long int callSign) |
| Sets the frequency and call sign for a Robo Interface or RF Data Link. | |
| long int | GetRFMode (FT_HANDLE hFt, long int *frequency, long int *callSign) |
| Gets the frequency and call sign of a Robo Interface or RF Data Link. | |
| long int | SetRealSerial (FT_HANDLE hFt, unsigned char bOn) |
| Switches between the real serial and 0001 of a device. | |
| char * | GetFtManufacturerStrg (FT_HANDLE hFt) |
| Gets the Manufacturer of the Interface. | |
| char * | GetFtShortNameStrg (FT_HANDLE hFt) |
| Gets the short name of the Interface. | |
| char * | GetFtLongNameStrg (FT_HANDLE hFt) |
| Gets the long name of the Interface. | |
| char | IsFtInterfaceConnected (FT_HANDLE hFt) |
| Tells if we successfuly got a connection to the Interface. | |
| char * | GetFtLibErrorString (long int dwErrorCode, long int dwTyp) |
| Gets the description of an error. | |
Detailed Description
Copyright (C) 2007 Erik Andresen erik@vontaene.de.
Open Source version of the fischertechnik ROBO Interface Library for Unix like systems
Communication is done through a "transfer area" this is constantly updated.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Definition in file libft.c.
Function Documentation
| long int CloseAllFtDevices | ( | ) |
| long int CloseFtDevice | ( | FT_HANDLE | hFt ) |
| long int CloseFtLib | ( | ) |
| long int DeleteFtProgram | ( | FT_HANDLE | hFt, |
| long int | dwMemBlock | ||
| ) |
| long int DownloadFtProgram | ( | FT_HANDLE | hFt, |
| long int | dwMemBlock, | ||
| unsigned char * | pbArray, | ||
| long int | dwSize, | ||
| long int | dwParameter, | ||
| unsigned char * | pbName, | ||
| long int | dwNameLen | ||
| ) |
Upload a program to the interface.
Upload (download from the perspective of the interface) a program to the interface.
- Parameters:
-
hFt Handle of the Interface dwMemBlock Destination 0 (Flash 1), 1 (Flash 2) or 2 (Ram) pbArray Pointer to the program to upload dwSize Size of the program to upload dwParameter 1 to Autostart this program, else 0. pbName Name of the program to upload dwNameLen Length of the name
- Returns:
- FTLIB_ERR_SUCCESS if you got lucky
| long int GetFtDeviceTyp | ( | FT_HANDLE | hFt ) |
Returns type of the interface.
This function will return the type of the interface that is behind the handle.
- Parameters:
-
hFt Handle of the device
- Returns:
- NO_FT_DEVICE, FT_INTELLIGENT_IF, FT_INTELLIGENT_IF_SLAVE, FT_ROBO_IF_COM, FT_ROBO_IF_USB, FT_ROBO_IF_IIM, FT_ROBO_IF_OVER_RF, FT_ROBO_IO_EXTENSION or FT_ROBO_RF_DATA_LINK
| long int GetFtDeviceTypeString | ( | FT_HANDLE | hFt, |
| char * | dest, | ||
| int | len | ||
| ) |
Returns a string that identifies the interface with human words.
This function will give you a human readable string like "Robo Interface" you can work with.
- Parameters:
-
hFt Handle of the device dest Buffer we can write the string to len Maximum length of this buffer
- Returns:
- FTLIB_ERR_SUCCESS or a failure
| long int GetFtFirmware | ( | FT_HANDLE | hFt ) |
| char* GetFtFirmwareStrg | ( | FT_HANDLE | hFt ) |
| char* GetFtLibErrorString | ( | long int | dwErrorCode, |
| long int | dwTyp | ||
| ) |
Gets the description of an error.
Will return a description of an error. The allocated space should be freed with free() later.
The return value is the constant as string if parameter dwTyp is 0, else a verbose description of the error.
- Parameters:
-
dwErrorCode Error Code dwTyp Type of the return value (see description)
- Returns:
- Pointer to a string (see description)
| char* GetFtLongNameStrg | ( | FT_HANDLE | hFt ) |
| char* GetFtManufacturerStrg | ( | FT_HANDLE | hFt ) |
| long int GetFtProgramName | ( | FT_HANDLE | hFt, |
| long int | dwMemBlock, | ||
| long int | dwSize, | ||
| void * | pName | ||
| ) |
Get the name of a program.
Will write the name of a program that has been uploaded to the interface to a given area.
- Parameters:
-
hFt Handle of the Interface dwMemBlock Destination 0 (Flash 1), 1 (Flash 2) or 2 (Ram) pName Pointer to the area where we can store the name dwSize Size of the area to store the name to
- Returns:
- FTLIB_ERR_SUCCESS or FTLIB_ERR_IF_NO_PROGRAM
| long int GetFtSerialNr | ( | FT_HANDLE | hFt ) |
| char* GetFtSerialNrStrg | ( | FT_HANDLE | hFt ) |
| char* GetFtShortNameStrg | ( | FT_HANDLE | hFt ) |
| int GetFtStatus | ( | FT_HANDLE | hFt, |
| int * | num | ||
| ) |
| FT_TRANSFER_AREA* GetFtTransferAreaAddress | ( | FT_HANDLE | hFt ) |
| FT_HANDLE GetFtUsbDeviceHandle | ( | unsigned char | Num ) |
doxygen ignore end
Gets the handle to a ft USB device.
Get the handle for the ft USB device with this number. Passing just 0 as argument will use the first device found.
Count the interfaces with GetNumFtUsbDevice()
- See also:
- GetNumFtUsbDevice()
- Parameters:
-
Num selected Interface. If unsure try 0.
- Returns:
- The ft device or NULL if error
| FT_HANDLE GetFtUsbDeviceHandleSerialNr | ( | long int | dwSN, |
| long int | dwTyp | ||
| ) |
Gets the handle to a ft USB device with a specific serial number.
Get the handle for the ft USB device with this number. Serial is 1 for most devices, unless explicitly changed in the device. Second argument can be FT_AUTO_TYPE.
- Parameters:
-
dwSN Serial of the USB Device dwTyp Type of the USB Device: FT_AUTO_TYPE, FT_ROBO_IF_USB, FT_ROBO_IO_EXTENSION, FT_ROBO_IF_OVER_RF or FT_ROBO_RF_DATA_LINK
- Returns:
- The ft device or NULL on error
| long int GetLibVersion | ( | ) |
| char* GetLibVersionStrg | ( | ) |
| unsigned int GetNumFtUsbDevice | ( | ) |
| long int GetRFMode | ( | FT_HANDLE | hFt, |
| long int * | frequency, | ||
| long int * | callSign | ||
| ) |
Gets the frequency and call sign of a Robo Interface or RF Data Link.
Sets the frequency and call sign which allows to control multiple Interfaces at one RF Data Link.
- Parameters:
-
hFt Handle of the Interface frequency Points to a place to store the frequency. callSign Points to a place to store the callSign. (Value will be 0 for the RF Data Link)
- Returns:
- FTLIB_ERR_SUCCESS on success
| long int InitFtLib | ( | ) |
| long int InitFtUsbDeviceList | ( | ) |
| char IsFtInterfaceConnected | ( | FT_HANDLE | hFt ) |
| long int IsFtLibInit | ( | ) |
| long int IsFtTransferActiv | ( | FT_HANDLE | hFt ) |
| FT_HANDLE OpenFtCommDevice | ( | char * | sDevice, |
| long int | dwTyp, | ||
| long int | dwZyklus | ||
| ) |
Gets the handle to a ft serial device.
Get the handle for the ft Serial device at the selected serial port.
- Parameters:
-
sDevice filename of your serial device, like /dev/ttyS0. dwTyp Interface type. FT_INTELLIGENT_IF, FT_INTELLIGENT_IF_SLAVE or FT_ROBO_IF_COM. dwZyklus Cycle to retrieve analog values (only II). Try 10.
- Returns:
- The ft device or NULL if error.
| long int OpenFtUsbDevice | ( | FT_HANDLE | hFt ) |
Opens this USB device.
This function will try to open the ft USB device that belongs to the ft handle hFt. You can get the ft handle with GetFtUsbDeviceHandle() or GetFtUsbDeviceHandleSerialNr().
- Parameters:
-
hFt ft USB Device to open
- Returns:
- Number >= 0 on success, < 0 on error
| long int ResetFtTransfer | ( | FT_HANDLE | hFt ) |
| long int SetFtDistanceSensorMode | ( | FT_HANDLE | hFt, |
| long int | dwMode, | ||
| long int | dwTol1, | ||
| long int | dwTol2, | ||
| long int | dwLevel1, | ||
| long int | dwLevel2, | ||
| long int | dwRepeat1, | ||
| long int | dwRepeat2 | ||
| ) |
Set the inputs D1 and D2 to distance oder voltage measuring.
This function allows to enable the inputs D1 and D2 to measure distances. Must be called before StartFtTransferArea()
Note by Hardware Vendor: "Since the operating mode of the D1 / D2 inputs can be set by means of software, we recommend that no voltage be supplied 'directly' to these connections in order to avoid damage to the interface during software errors. Since the inputs are highly resistive, a resistance of approximately 200 Ohm - 470 Ohm should be directly connected to the D1 / D2 socket (series connection). We recommend to connect the voltage range to be measured 'behind' it."
- Parameters:
-
hFt Handle of the Interface dwMode Set mode to IF_DS_INPUT_VOLTAGE (measure voltage) or IF_DS_INPUT_DISTANCE (measure distance) dwTol1 Range of tolerance for D1. Try IF_DS_INPUT_TOL_STD (20). dwTol2 Range of tolerance for D2. Try IF_DS_INPUT_TOL_STD (20). dwLevel1 Threshold for D1. Try 100. dwLevel2 Threshold for D2. Try 100. dwRepeat1 Repition value for D1. Try IF_DS_INPUT_REP_STD (3). dwRepeat2 Repition value for D2. Try IF_DS_INPUT_REP_STD (3).
- Returns:
- FTLIB_ERR_SUCCESS on success
| long int SetFtProgramActiv | ( | FT_HANDLE | hFt, |
| long int | dwMemBlock | ||
| ) |
| long int SetRealSerial | ( | FT_HANDLE | hFt, |
| unsigned char | bOn | ||
| ) |
Switches between the real serial and 0001 of a device.
Every ft Interface is shipped with 0001 as serial. Nevertheless each has its own serial which can be activated.
- Parameters:
-
hFt Handle of the Interface bOn 0 to use 0001, else the real serial
- Returns:
- FTLIB_ERR_SUCCESS on success
| long int SetRFMode | ( | FT_HANDLE | hFt, |
| long int | frequency, | ||
| long int | callSign | ||
| ) |
Sets the frequency and call sign for a Robo Interface or RF Data Link.
Sets the frequency and call sign which allows to control multiple Interfaces at one RF Data Link. The value won't be lost on power failure.
- Parameters:
-
hFt Handle of the Interface frequency to use. May be between 2 and 80. callSign call sign for this Interface. May be between 1 and 8. (ignored for the RF Data Link)
- Returns:
- FTLIB_ERR_SUCCESS on success
| long int StartFtProgram | ( | FT_HANDLE | hFt, |
| long int | dwMemBlock | ||
| ) |
| long int StartFtTransferArea | ( | FT_HANDLE | hFt, |
| NOTIFICATION_EVENTS * | ev | ||
| ) |
Starts the communication thread.
This function is needed to start the communication with the interface in passive mode. Get the handle with GetFtUsbDeviceHandle(), GetFtUsbDeviceHandleSerialNr() or OpenFtCommDevice().
- Parameters:
-
hFt Handle of the interface. ignored The second argument is ignored in this version.
- Returns:
- Everything except FTLIB_ERR_SUCCESS indicates an error.
| long int StartFtTransferAreaWithCommunication | ( | FT_HANDLE | hFt, |
| NOTIFICATION_EVENTS * | ignored | ||
| ) |
Starts the communication thread.
Since notification are ignored in this version, will just call StartFtTransferArea().
- See also:
- StartFtTransferArea()
| long int StopFtProgram | ( | FT_HANDLE | hFt ) |
| long int StopFtTransferArea | ( | FT_HANDLE | hFt ) |
Stops the communication thread.
- Warning:
- Will block a few microseconds until thread stopped.
This function will stop the communication thread.
- See also:
- StartFtTransferArea()
- Parameters:
-
hFt Handle of the Interface.
- Returns:
- Everything except FTLIB_ERR_SUCCESS indicates an error.
Generated on Tue Jul 12 2022 20:02:51 by
1.7.2