@@ -15,6 +15,14 @@ const serial = {
1515 transmitting : false ,
1616 outputBuffer : [ ] ,
1717
18+ serialDevices : [
19+ { 'vendorId' : 1027 , 'productId' : 24577 } , // FT232R USB UART
20+ { 'vendorId' : 1155 , 'productId' : 22336 } , // STM Electronics Virtual COM Port
21+ { 'vendorId' : 4292 , 'productId' : 60000 } , // CP210x
22+ { 'vendorId' : 4292 , 'productId' : 60001 } , // CP210x
23+ { 'vendorId' : 4292 , 'productId' : 60002 } , // CP210x
24+ ] ,
25+
1826 connect : function ( path , options , callback ) {
1927 const self = this ;
2028 const testUrl = path . match ( / ^ t c p : \/ \/ ( [ A - Z a - z 0 - 9 \. - ] + ) (?: \: ( \d + ) ) ? $ / ) ;
@@ -258,13 +266,24 @@ const serial = {
258266 }
259267 } ,
260268 getDevices : function ( callback ) {
269+ const self = this ;
270+
261271 chrome . serial . getDevices ( function ( devices_array ) {
262272 const devices = [ ] ;
273+ let showAllSerialDevices = false ;
274+
263275 devices_array . forEach ( function ( device ) {
264- devices . push ( {
265- path : device . path ,
266- displayName : device . displayName ,
267- } ) ;
276+ ConfigStorage . get ( 'showAllSerialDevices' , res => showAllSerialDevices = res . showAllSerialDevices ) ;
277+ const isKnownSerialDevice = self . serialDevices . some ( el => el . vendorId === device . vendorId ) && self . serialDevices . some ( el => el . productId === device . productId ) ;
278+
279+ if ( isKnownSerialDevice || showAllSerialDevices ) {
280+ devices . push ( {
281+ path : device . path ,
282+ displayName : device . displayName ,
283+ vendorId : device . vendorId ,
284+ productId : device . productId ,
285+ } ) ;
286+ }
268287 } ) ;
269288
270289 callback ( devices ) ;
0 commit comments