diff options
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;
+}
|
