tailieunhanh - programming LEGO MINDSTORMS phần 3
Điều này là khá hữu ích, nhưng cung cấp cho bạn hầu như không có sự linh hoạt trong cách thức hoạt động của vòng lặp. Mặc dù bạn có thể thay đổi giá trị thặng dư, hoặc thậm chí làm tăng tiêu cực, bằng cách sử dụng cơ sở Bước, vòng lặp luôn luôn hoạt động bằng cách đếm, và các kiểm tra cho dù thoát khỏi | 72 Chapter 2 The Java Communications API public CommPort getCommPort String portName int portType Win32USBPort port new Win32USBPort try if portName 0 port null catch ioexception port null return port In initialize above one can populate the port list IDs. Its counterpart Win32Driver added the lists for both serial and parallel ports to CommPortldentifier. Here I added the possibility of having two towers. It s a meager attempt because we don t have access to a native method that will enumerate all the towers present. Again this is not a full-fledged USB driver we re wrapping some access to the LEGO Company s native USB specific port names listed above were as provided by LEGO s SDK documentation. In theory we have all the parts in place and we add an entry to the properties file Windows Serial Driver Driver Windows USB Driver for Lego Mindstorms Driver This should work but it doesn t. In fact Win32USBPort won t It s because CommPort s initializer is package private all of its subclasses must reside inside the is a serious limitation because we can t just drop in a new type of port without breaking package can t deliver . classes outside of the because the extension would then cease to be standard. What did do to get around this limitation Technically the way around it was to have an additional abstraction between it and The Java Communications API Chapter 2 73 CommPort. In that case it was able to extend without a s because Java Comm supports serial and parallel ports out of the would still run into the problem of having to create a we weren t intending to introduce generic USB port support we just want to add our customized USB port into the mix. Adding generic USB support would require changing the core .
đang nạp các trang xem trước