Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sfp-plus-i2c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
sfp-plus-i2c
Commits
98f13730
Commit
98f13730
authored
May 23, 2017
by
Vincent van Beveren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Linux issues
parent
a4f8701d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
148 additions
and
67 deletions
+148
-67
README
README
+24
-1
MultiSFPProvider.java
sw/jsfp/src/nl/nikhef/sfp/MultiSFPProvider.java
+6
-2
.classpath
sw/rebus/.classpath
+2
-1
org.eclipse.jdt.core.prefs
sw/rebus/.settings/org.eclipse.jdt.core.prefs
+4
-0
jna-4.4.0.jar
sw/rebus/lib/jna-4.4.0.jar
+0
-0
jna-platform-4.4.0.jar
sw/rebus/lib/jna-platform-4.4.0.jar
+0
-0
FTD2XX.java
sw/rebus/src/com/ftdi/FTD2XX.java
+55
-53
FTDevice.java
sw/rebus/src/com/ftdi/FTDevice.java
+37
-10
TestBinding.java
sw/rebus/src/nl/nikhef/rebus/ftdi/TestBinding.java
+20
-0
No files found.
README
View file @
98f13730
SFP-PLUS-I2C
------------
============
Running on Ubuntu
=================
To run SaFariPark on Ubuntu two things need to happen:
1) The rights of the FTDI device must be relaxed such that any use has read and write permissions
2) the ftdi_sio driver must be prevented from loading, as it will interfere with opening the device
Relaxing driver rights
----------------------
Create a file named 90-ftdi in /etc/udev/rules.d/ and put in the following statement:
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", MODE="0666"
Prevent loading of the ftdi_sio driver
--------------------------------------
Edit the file /etc/modprobe.d/blacklist.conf and append the following line:
blacklist ftdi_sio
Note: This will prevent any FTDI based device from being loaded as a USB serial converted.
sw/jsfp/src/nl/nikhef/sfp/MultiSFPProvider.java
View file @
98f13730
...
...
@@ -46,12 +46,16 @@ public class MultiSFPProvider extends SFPProviderBase
{
devs
=
FTDevice
.
getDevices
(
true
);
// System.out.printf("FTDevice.getDevices() Found %d devices\n", devs.size());
}
for
(
FTDevice
devRaw
:
devs
)
{
if
(
devRaw
.
getDevType
()
==
DeviceType
.
DEVICE_2232H
&&
devRaw
.
getDevDescription
().
equals
(
"MultiSFP A"
))
{
// System.out.println("Device: " + devRaw);
// XXX On Linux the MultiSFP A is descriptor is not generated once opened. But B remains. So we sync on that.
//
if
(
devRaw
.
getDevType
()
==
DeviceType
.
DEVICE_2232H
&&
devRaw
.
getDevDescription
().
equals
(
"MultiSFP B"
))
{
// Only get the primary 'A' device, we know the second.
String
serial
=
devRaw
.
getDevSerialNumber
();
...
...
sw/rebus/.classpath
View file @
98f13730
...
...
@@ -3,6 +3,7 @@
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"
/>
<classpathentry
kind=
"src"
path=
"/nikhef-tools"
/>
<classpathentry
kind=
"lib"
path=
"lib/jna-4.3.0.jar"
/>
<classpathentry
kind=
"lib"
path=
"lib/jna-4.4.0.jar"
/>
<classpathentry
kind=
"lib"
path=
"lib/jna-platform-4.4.0.jar"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
sw/rebus/.settings/org.eclipse.jdt.core.prefs
View file @
98f13730
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
sw/rebus/lib/jna-4.4.0.jar
0 → 100644
View file @
98f13730
File added
sw/rebus/lib/jna-platform-4.4.0.jar
0 → 100644
View file @
98f13730
File added
sw/rebus/src/com/ftdi/FTD2XX.java
View file @
98f13730
This diff is collapsed.
Click to expand it.
sw/rebus/src/com/ftdi/FTDevice.java
View file @
98f13730
...
...
@@ -23,9 +23,13 @@
*/
package
com
.
ftdi
;
import
com.ftdi.FTD2XX.FT_DEVICE_LIST_INFO_NODE
;
import
com.sun.jna.Memory
;
import
com.sun.jna.Pointer
;
import
com.sun.jna.ptr.ByteByReference
;
import
com.sun.jna.ptr.IntByReference
;
import
com.sun.jna.ptr.PointerByReference
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
...
...
@@ -35,6 +39,8 @@ import java.util.List;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.nikhef.tools.Utils
;
/**
* Java class to communicate easily to a FTDI device.
* @author Peter Kocsis <p. kocsis. 2. 7182 at gmail.com>
...
...
@@ -44,14 +50,14 @@ public class FTDevice {
static
private
final
FTD2XX
ftd2xx
=
FTD2XX
.
INSTANCE
;
private
final
int
devID
,
devLocationID
,
flag
;
private
final
DeviceType
devType
;
private
int
ftHandle
;
private
Pointer
ftHandle
;
private
final
String
devSerialNumber
,
devDescription
;
private
FTDeviceInputStream
fTDeviceInputStream
=
null
;
private
FTDeviceOutputStream
fTDeviceOutputStream
=
null
;
private
boolean
open
=
false
;
private
FTDevice
(
DeviceType
devType
,
int
devID
,
int
devLocationID
,
String
devSerialNumber
,
String
devDescription
,
int
ftHandle
,
String
devSerialNumber
,
String
devDescription
,
Pointer
ftHandle
,
int
flag
)
{
this
.
devType
=
devType
;
this
.
devID
=
devID
;
...
...
@@ -126,14 +132,14 @@ public class FTDevice {
@Override
public
int
hashCode
()
{
int
hash
=
5
;
hash
=
97
*
hash
+
this
.
ftHandle
;
hash
=
97
*
hash
+
this
.
ftHandle
.
hashCode
()
;
return
hash
;
}
@Override
public
String
toString
()
{
return
"FTDevice{"
+
"devDescription="
+
devDescription
+
", devSerialNumber="
+
devSerialNumber
+
'}'
;
+
", devSerialNumber="
+
devSerialNumber
+
"devLocationId="
+
devLocationID
+
'}'
;
}
private
static
void
ensureFTStatus
(
int
ftstatus
)
throws
FTD2XXException
{
...
...
@@ -147,7 +153,7 @@ public class FTDevice {
IntByReference
devType
=
new
IntByReference
();
IntByReference
devID
=
new
IntByReference
();
IntByReference
locID
=
new
IntByReference
();
IntByReference
ftHandle
=
new
Int
ByReference
();
PointerByReference
ftHandle
=
new
Pointer
ByReference
();
Memory
devSerNum
=
new
Memory
(
16
);
Memory
devDesc
=
new
Memory
(
64
);
...
...
@@ -182,9 +188,10 @@ public class FTDevice {
ArrayList
<
FTDevice
>
devs
=
new
ArrayList
<
FTDevice
>(
devNum
.
getValue
());
for
(
int
i
=
0
;
i
<
devNum
.
getValue
();
i
++)
{
for
(
int
i
=
0
;
i
<
devNum
.
getValue
();
i
++)
{
FTDevice
device
=
getXthDevice
(
i
);
//device is occupied?
if
(
isIncludeOpenedDevices
)
{
devs
.
add
(
device
);
}
else
{
...
...
@@ -192,17 +199,37 @@ public class FTDevice {
devs
.
add
(
device
);
}
}
}
Logger
.
getLogger
(
FTDevice
.
class
.
getName
()).
log
(
Level
.
FINE
,
"Found devs: {0} (All:{1})"
,
new
Object
[]{
devs
.
size
(),
devNum
.
getValue
()});
return
devs
;
}
private
static
String
fromNullTerminated
(
byte
[]
array
)
{
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
if
(
array
[
i
]
==
0
)
{
return
new
String
(
array
,
0
,
i
);
}
}
return
new
String
(
array
);
}
/**
private
static
FTDevice
getFromInfoNode
(
FT_DEVICE_LIST_INFO_NODE
info
)
{
return
new
FTDevice
(
DeviceType
.
values
()[
info
.
Type
],
info
.
ID
,
info
.
LocId
,
fromNullTerminated
(
info
.
SerialNumber
),
fromNullTerminated
(
info
.
Description
),
info
.
ftHandle
,
info
.
Flags
);
}
/**
* Get the connected FTDI devices. It will not contain opened devices.
* @param description Filtering option, exact match need.
* @return List contain available FTDI devices.
...
...
@@ -302,7 +329,7 @@ public class FTDevice {
public
void
open
()
throws
FTD2XXException
{
Memory
memory
=
new
Memory
(
16
);
memory
.
setString
(
0
,
devSerialNumber
);
IntByReference
handle
=
new
Int
ByReference
();
PointerByReference
handle
=
new
Pointer
ByReference
();
ensureFTStatus
(
ftd2xx
.
FT_OpenEx
(
memory
,
FTD2XX
.
FT_OPEN_BY_SERIAL_NUMBER
,
handle
));
this
.
ftHandle
=
handle
.
getValue
();
...
...
sw/rebus/src/nl/nikhef/rebus/ftdi/TestBinding.java
0 → 100644
View file @
98f13730
package
nl
.
nikhef
.
rebus
.
ftdi
;
import
com.ftdi.FTD2XXException
;
import
com.ftdi.FTDevice
;
public
class
TestBinding
{
public
static
void
main
(
String
[]
args
)
throws
FTD2XXException
{
for
(
FTDevice
dev:
FTDevice
.
getDevices
())
{
System
.
out
.
println
(
dev
);
dev
.
open
();
dev
.
write
(
0
);
dev
.
close
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment