diff options
| author | Tero Kontkanen <tero.k@granitedevices.com> | 2017-08-23 14:44:10 +0300 |
|---|---|---|
| committer | Tero Kontkanen <tero.k@granitedevices.com> | 2017-08-23 14:44:10 +0300 |
| commit | 98a89371108bbcdedb201caf7be8b82a323e60cc (patch) | |
| tree | 915a5596c632256ab77d5dc42236644307ea3b66 /simplemotion.c | |
| parent | 5d21340928cd46b3cb97cae0b9c707a71ef9ced0 (diff) | |
| parent | 4176d9358a526ff207bb5f4d127f4143a632d748 (diff) | |
| download | SimpleMotionV2-98a89371108bbcdedb201caf7be8b82a323e60cc.tar.gz SimpleMotionV2-98a89371108bbcdedb201caf7be8b82a323e60cc.zip | |
Merge branch 'feature/port_driver_ftdi_d2xx' into develop
Diffstat (limited to 'simplemotion.c')
| -rw-r--r-- | simplemotion.c | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/simplemotion.c b/simplemotion.c index 58627cb..1211d63 100644 --- a/simplemotion.c +++ b/simplemotion.c @@ -73,17 +73,18 @@ void smDebug( smbus handle, smVerbosityLevel verbositylevel, char *format, ...) va_list fmtargs;
char buffer[1024];
-
- //check if bus handle is valid & opened
- if(smIsHandleOpen(handle)==smfalse) return;
-
if(smDebugOut!=NULL && verbositylevel <= smDebugThreshold )
{
va_start(fmtargs,format);
vsnprintf(buffer,sizeof(buffer)-1,format,fmtargs);
va_end(fmtargs);
if(handle>=0)
- fprintf(smDebugOut,"%s: %s",smBus[handle].busDeviceName, buffer);
+ {
+ if(smIsHandleOpen(handle)==smtrue)
+ {
+ fprintf(smDebugOut,"%s: %s",smBus[handle].busDeviceName, buffer);
+ }
+ }
else
fprintf(smDebugOut,"SMLib: %s",buffer);//no handle given
}
@@ -150,7 +151,7 @@ smuint8 calcCRC8Buf( smuint8 *buf, int len, int crcinit ) SM_STATUS smSetTimeout( smuint16 millsecs )
{
- if(millsecs<=5000)
+ if(millsecs<=5000 && millsecs>=1)
{
readTimeoutMs=millsecs;
return SM_OK;
@@ -953,3 +954,36 @@ SM_STATUS resetCumulativeStatus( const smbus handle ) return SM_OK;
}
+
+/** Return number of bus devices found. details of each device may be consequently fetched by smGetBusDeviceDetails() */
+smint smGetNumberOfDetectedBuses()
+{
+ return smBDGetNumberOfDetectedBuses();
+}
+
+/** Fetch information of detected bus nodes at certain index. Example:
+
+ smint num=smGetNumberOfDetectedBuses();
+ for(int i=0;i<num;i++)
+ {
+ SM_BUS_DEVICE_INFO info;
+ SM_STATUS s=smGetBusDeviceDetails(i,&info);
+ if(s==SM_OK)
+ {
+ ...do something with info...
+ }
+ else
+ {
+ ...report error...
+ }
+ }
+*/
+LIB SM_STATUS smGetBusDeviceDetails( smint index, SM_BUS_DEVICE_INFO *info )
+{
+ smbool ok=smBDGetBusDeviceDetails(index,info);
+
+ if(ok==smtrue)
+ return SM_OK;
+ else
+ return SM_ERR_NODEVICE;
+}
|
