[squeak-dev] The Trunk: System-dtl.153.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Oct 4 18:43:44 UTC 2009


David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.153.mcz

==================== Summary ====================

Name: System-dtl.153
Author: dtl
Time: 4 October 2009, 2:39:40 am
UUID: 4da4372f-e1c7-4916-8f92-e3e6b52ed6e9
Ancestors: System-cwp.152

Add support for named serial ports to image, reference Mantis 7286.

Change Set:		SerialPortManagingNamedNodes-sk
Date:			13 January 2009
Author:			Séverin Lemaignan

Recent Linux kernels don't mount most serial
devices on /dev/ttySxx, but on more specific nodes, like /dev/ttyACMxx
for modems, /dev/ttyUSBxx for certain USB->COM converters, etc.

This change set adapt the SerialPort class to a new version of the VM SerialPlugin.

=============== Diff against System-cwp.152 ===============

Item was changed:
  ----- Method: SerialPort>>openPort: (in category 'open/close') -----
+ openPort: portId 
+ 	"Open the given serial port, using the settings specified by my
+ 	instance variables."
- openPort: portNumber
- 	"Open the given serial port, using the settings specified by my instance variables. If the port cannot be opened, such as when it is alreay in use, answer nil."  "(DNS)"
- 
  	self close.
+ 	portId isString
+ 		ifTrue: [self
+ 				primOpenPortByName: portId
+ 				baudRate: baudRate
+ 				stopBitsType: stopBitsType
+ 				parityType: parityType
+ 				dataBits: dataBits
+ 				inFlowControlType: inputFlowControlType
+ 				outFlowControlType: outputFlowControlType
+ 				xOnByte: xOnByte
+ 				xOffByte: xOffByte]
+ 		ifFalse: [self
+ 				primOpenPort: portId
+ 				baudRate: baudRate
+ 				stopBitsType: stopBitsType
+ 				parityType: parityType
+ 				dataBits: dataBits
+ 				inFlowControlType: inputFlowControlType
+ 				outFlowControlType: outputFlowControlType
+ 				xOnByte: xOnByte
+ 				xOffByte: xOffByte].
+ 	port := portId!
- 	(self primClosePort: portNumber) isNil ifTrue: [
- 		^ nil ].
- 	(self primOpenPort: portNumber
- 		baudRate: baudRate
- 		stopBitsType: stopBitsType
- 		parityType: parityType
- 		dataBits: dataBits
- 		inFlowControlType: inputFlowControlType
- 		outFlowControlType: outputFlowControlType
- 		xOnByte: xOnByte
- 		xOffByte: xOffByte) isNil ifTrue: [
- 			^ nil ].
- 	port := portNumber
- !

Item was added:
+ ----- Method: SerialPort>>primWritePortByName:from:startingAt:count: (in category 'primitives') -----
+ primWritePortByName: portName from: byteArray startingAt: startIndex count: count 
+ 	<primitive: 'primitiveSerialPortWriteByName' module:'SerialPlugin'>
+ 	self primitiveFailed!

Item was changed:
  ----- Method: SerialPort>>readString (in category 'input/output') -----
  readString
+ 	"Answer a String read from this serial port. Answer the empty
+ 	String if no data is available. The port must be open."
- 	"Answer a String read from this serial port. Answer the empty String if no data is available. The port must be open."
- 
  	| buf count |
  	buf := String new: 1000.
+ 	count := port isString ifTrue:[self
+ 				primReadPortByName: port
+ 				into: buf
+ 				startingAt: 1
+ 				count: buf size.]
+ ifFalse:[self
+ 				primReadPort: port
+ 				into: buf
+ 				startingAt: 1
+ 				count: buf size.].
+ 	^ buf copyFrom: 1 to: count!
- 	count := self primReadPort: port into: buf startingAt: 1 count: buf size.
- 	^ buf copyFrom: 1 to: count
- !

Item was added:
+ ----- Method: SerialPort>>primReadPortByName:into:startingAt:count: (in category 'primitives') -----
+ primReadPortByName: portName into: byteArray startingAt: startIndex count: count 
+ 	<primitive: 'primitiveSerialPortReadByName' module:'SerialPlugin'>
+ 	self primitiveFailed!

Item was changed:
  ----- Method: SerialPort>>close (in category 'open/close') -----
  close
  	"Close the serial port. Do nothing if the port is not open."
+ 	port
+ 		ifNotNil: [port isString ifTrue:[self primClosePortByName: port]
+  ifFalse:[self primClosePort:port]].
+ 	port := nil!
- 
- 	port ifNotNil: [self primClosePort: port].
- 	port := nil.
- !

Item was changed:
  ----- Method: SerialPort>>readInto:startingAt: (in category 'input/output') -----
+ readInto: aStringOrByteArray startingAt: index 
+ 	"Read data into the given String or ByteArray object starting at
+ 	the given index, and answer the number of bytes read. Does
+ 	not go past the end of the given String or ByteArray."
+ 	^ port isString
+ 				ifTrue: [self primReadPortByName: port
+ 		into: aStringOrByteArray
+ 		startingAt: index
+ 		count: aStringOrByteArray size - index + 1]
+ 				ifFalse: [self primReadPort: port
- readInto: aStringOrByteArray startingAt: index
- 	"Read data into the given String or ByteArray object starting at the given index, and answer the number of bytes read. Does not go past the end of the given String or ByteArray."
- 
- 	^ self primReadPort: port
  		into: aStringOrByteArray
  		startingAt: index
+ 		count: aStringOrByteArray size - index + 1].
+ 		!
- 		count: (aStringOrByteArray size - index) + 1.
- !

Item was added:
+ ----- Method: SerialPort>>primClosePortByName: (in category 'primitives') -----
+ primClosePortByName: portName
+ 	<primitive: 'primitiveSerialPortCloseByName' module:'SerialPlugin'>
+ 	^ nil"(DNS)"
+ 	"self primitiveFailed."!

Item was changed:
  ----- Method: SerialPort>>readByteArray (in category 'input/output') -----
  readByteArray
+ 	"Answer a ByteArray read from this serial port. Answer an
+ 	empty ByteArray if no data is available. The port must be
+ 	open. "
- 	"Answer a ByteArray read from this serial port. Answer an empty ByteArray if no data is available. The port must be open."
- 
  	| buf count |
  	buf := ByteArray new: 1000.
+ 	count := port isString
+ 				ifTrue: [self
+ 						primReadPortByName: port
+ 						into: buf
+ 						startingAt: 1
+ 						count: buf size]
+ 				ifFalse: [self
+ 						primReadPort: port
+ 						into: buf
+ 						startingAt: 1
+ 						count: buf size].
+ 	^ buf copyFrom: 1 to: count!
- 	count := self primReadPort: port into: buf startingAt: 1 count: buf size.
- 	^ buf copyFrom: 1 to: count
- !

Item was added:
+ ----- Method: SerialPort>>primOpenPortByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
+ primOpenPortByName: portName baudRate: baud stopBitsType: stop parityType: parity dataBits: numDataBits inFlowControlType: inFlowCtrl outFlowControlType: outFlowCtrl xOnByte: xOn xOffByte: xOff 
+ 	<primitive: 'primitiveSerialPortOpenByName' module:'SerialPlugin'>
+ 	^ nil"(DNS)"!

Item was changed:
  ----- Method: SerialPort>>nextPutAll: (in category 'input/output') -----
+ nextPutAll: aStringOrByteArray 
+ 	"Send the given bytes out this serial port. The port must be
+ 	open. "
+ 	^ port isString
+ 		ifTrue: [self
+ 		primWritePortByName: port
+ 		from: aStringOrByteArray
+ 		startingAt: 1
+ 		count: aStringOrByteArray size]
+ 		ifFalse: [self
+ 		primWritePort: port
- nextPutAll: aStringOrByteArray
- 	"Send the given bytes out this serial port. The port must be open."
- 
- 	^ self primWritePort: port
  		from: aStringOrByteArray
  		startingAt: 1
+ 		count: aStringOrByteArray size]
- 		count: aStringOrByteArray size.
  !




More information about the Squeak-dev mailing list