Categories – Best thing since sliced bread.
So here I was trying to make a Mac produce the little endian binary format that the Momento needs and so I thought I’d better extend NSMutableData to give it some LittleEndian “append” capability. So, I set up my class and the inheritance from but I kept getting an error that -length was only enabled for the abstract class. Then I discovered categories.
You can declare a new class as a category of an existing class (the convention is to name your files baseclass+category.{m,h}:
@interface NSMutableData (endian)
- (void)appendLittle16:(const uint16_t)value;
- (void)appendLittle32:(const uint32_t)value;
@end
As long as you import this header and link the implementation, your NSMutableData objects suddenly have this extra capability.
Instead of doing things with [super] as you normally do with an inherited class, you operate on [self].
@implementation NSMutableData (endian)
- (void)appendLittle16:(const uint16_t)value
{
uint16_t little16 = CFSwapInt16HostToLittle(value);
[self appendBytes:&little16 length:sizeof(little16)];
}
This makes the code to create packets for the Momento much simpler:
NSMutableData *data;
data=[[NSMutableData alloc] initWithCapacity:20];
[data appendLittle32:2];
[data appendBytes:&UUID length:sizeof(uuid_t)];
Comments are closed.
about 2 years ago
Keep posting stuff like this i really like it
about 2 years ago
I recently traded my Lyjam LCD with a Momento. I like to ti=witch with firmware and stuff and so I stumbled upon your blog. I hop you can succeed! I’ll follw your progress! Gooed luck. If you need testing, just mail me.
Kind regards, Gerben (The Netherlands)
about 1 year ago
Not sure if you have tried this but I use my 70 and 100 to stream photo’s from a Twonkymedia server on my NAS. Not quite online, but I can add media via FTP to my NAS from anywhere in the world
about 1 year ago
Jason – any more information of how you did it?
about 1 year ago
Found this site on google, nice to see people playing with the momento! I just bought it today to play with the hardware
The problem is that my Momento was a refurbish and it doesn’t work… It seem to be in bootloader mode. It’s detected as a “SEC S3C2410X Test B/D”.
Here’s what i did:
1- Downloaded SEC driver http://www.multiupload.com/OFPTQZ2ANY
Status with DNW
===== USB DEVICE STATUS =====
USB_CONFIGURATION_DESCRIPTOR
bLength = 0×9, decimal 9
bDescriptorType = 0×2 ( USB_CONFIGURATION_DESCRIPTOR_TYPE )
wTotalLength = 0×20, decimal 32
bNumInterfaces = 0×1, decimal 1
bConfigurationValue = 0×1, decimal 1
iConfiguration = 0×0, decimal 0
bmAttributes = 0xc0 ( ??? UNKNOWN!! )
MaxPower = 0×19, decimal 25
—————————–
USB_INTERFACE_DESCRIPTOR #0
bLength = 0×9
bDescriptorType = 0×4 ( USB_INTERFACE_DESCRIPTOR_TYPE )
bInterfaceNumber = 0×0
bAlternateSetting = 0×0
bNumEndpoints = 0×2
bInterfaceClass = 0xff
bInterfaceSubClass = 0×0
bInterfaceProtocol = 0×0
bInterface = 0×0
—————————–
USB_ENDPOINT_DESCRIPTOR for Pipe00
bLength = 0×7
bDescriptorType = 0×5 ( USB_ENDPOINT_DESCRIPTOR_TYPE )
bEndpointAddress= 0×81 ( INPUT )
bmAttributes= 0×2 ( USB_ENDPOINT_TYPE_BULK )
wMaxPacketSize= 0×20, decimal 32
bInterval = 0×0, decimal 0
—————————–
USB_ENDPOINT_DESCRIPTOR for Pipe01
bLength = 0×7
bDescriptorType = 0×5 ( USB_ENDPOINT_DESCRIPTOR_TYPE )
bEndpointAddress= 0×3 ( OUTPUT )
bmAttributes= 0×2 ( USB_ENDPOINT_TYPE_BULK )
wMaxPacketSize= 0×20, decimal 32
bInterval = 0×0, decimal 0
—————————–
2- Devicetree detect it as \Driver\SecBulk and \Driver00000da
3- Can’t open USB with Mtty http://forum.xda-developers.com/attachment.php?attachmentid=71806&d=1203597568
Any ideas? Does anyone have a firmware/ROM dump of the momento?
Thanks in advance,